mirror of
https://github.com/Redocly/redoc.git
synced 2025-02-12 16:00:33 +03:00
Fixed side menu overlapped site footer (#75)
This commit is contained in:
parent
b649d52c39
commit
a8d98b127b
|
@ -32,11 +32,24 @@ export class StickySidebar implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePosition() {
|
updatePosition() {
|
||||||
|
var stuck = false;
|
||||||
if ( this.scrollY + this.scrollYOffset() >= this.$redocEl.offsetTop) {
|
if ( this.scrollY + this.scrollYOffset() >= this.$redocEl.offsetTop) {
|
||||||
this.stick();
|
this.stick();
|
||||||
|
stuck = true;
|
||||||
} else {
|
} else {
|
||||||
this.unstick();
|
this.unstick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( this.scrollY + window.innerHeight - this.scrollYOffset() >= this.$redocEl.scrollHeight) {
|
||||||
|
this.stickBottom();
|
||||||
|
stuck = true;
|
||||||
|
} else {
|
||||||
|
this.unstickBottom();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!stuck) {
|
||||||
|
DOM.setStyle(this.$element, 'position', 'absolute');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stick() {
|
stick() {
|
||||||
|
@ -45,19 +58,33 @@ export class StickySidebar implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
unstick() {
|
unstick() {
|
||||||
DOM.setStyle(this.$element, 'position', 'absolute');
|
|
||||||
DOM.setStyle(this.$element, 'top', '0');
|
DOM.setStyle(this.$element, 'top', '0');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stickBottom() {
|
||||||
|
DOM.setStyle(this.$element, 'position', 'fixed');
|
||||||
|
var offset = this.scrollY + this.scrollParentHeight - (this.$redocEl.scrollHeight + this.$redocEl.offsetTop);
|
||||||
|
DOM.setStyle(this.$element, 'bottom', offset + 'px');
|
||||||
|
}
|
||||||
|
|
||||||
|
unstickBottom() {
|
||||||
|
DOM.setStyle(this.$element, 'bottom', '0');
|
||||||
|
}
|
||||||
|
|
||||||
get scrollY() {
|
get scrollY() {
|
||||||
return (this.scrollParent.pageYOffset != undefined) ? this.scrollParent.pageYOffset : this.scrollParent.scrollTop;
|
return (this.scrollParent.pageYOffset != undefined) ? this.scrollParent.pageYOffset : this.scrollParent.scrollTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get scrollParentHeight() {
|
||||||
|
return (this.scrollParent.innerHeight != undefined) ? this.scrollParent.innerHeight : this.scrollParent.clientHeight;
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
// FIXME use more reliable code
|
// FIXME use more reliable code
|
||||||
this.$redocEl = this.$element.offsetParent.parentNode || DOM.defaultDoc().body;
|
this.$redocEl = this.$element.offsetParent.parentNode || DOM.defaultDoc().body;
|
||||||
this.bind();
|
this.bind();
|
||||||
this.updatePosition();
|
setTimeout(() => this.updatePosition());
|
||||||
|
//this.updatePosition()
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user