mirror of
https://github.com/Redocly/redoc.git
synced 2025-02-07 21:40:32 +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() {
|
||||
var stuck = false;
|
||||
if ( this.scrollY + this.scrollYOffset() >= this.$redocEl.offsetTop) {
|
||||
this.stick();
|
||||
stuck = true;
|
||||
} else {
|
||||
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() {
|
||||
|
@ -45,19 +58,33 @@ export class StickySidebar implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
unstick() {
|
||||
DOM.setStyle(this.$element, 'position', 'absolute');
|
||||
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() {
|
||||
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() {
|
||||
// FIXME use more reliable code
|
||||
this.$redocEl = this.$element.offsetParent.parentNode || DOM.defaultDoc().body;
|
||||
this.bind();
|
||||
this.updatePosition();
|
||||
setTimeout(() => this.updatePosition());
|
||||
//this.updatePosition()
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user