mirror of
https://github.com/Redocly/redoc.git
synced 2025-07-12 17:22:29 +03:00
fix mobile nav
This commit is contained in:
parent
547cf0ceab
commit
7380f89482
|
@ -31,10 +31,10 @@ export class SideMenu extends BaseComponent {
|
||||||
this.options = optionsService.options;
|
this.options = optionsService.options;
|
||||||
this.detectorRef = detectorRef;
|
this.detectorRef = detectorRef;
|
||||||
|
|
||||||
this.menuService.changed.subscribe((cat, item) => this.changed(cat, item));
|
this.menuService.changed.subscribe((evt) => this.changed(evt));
|
||||||
}
|
}
|
||||||
|
|
||||||
changed(cat, item) {
|
changed({cat, item}) {
|
||||||
this.activeCatCaption = cat.name || '';
|
this.activeCatCaption = cat.name || '';
|
||||||
this.activeItemCaption = item && item.summary || '';
|
this.activeItemCaption = item && item.summary || '';
|
||||||
|
|
||||||
|
@ -54,11 +54,10 @@ export class SideMenu extends BaseComponent {
|
||||||
this.$mobileNav = this.dom.querySelector(this.$element, '.mobile-nav');
|
this.$mobileNav = this.dom.querySelector(this.$element, '.mobile-nav');
|
||||||
this.$resourcesNav = this.dom.querySelector(this.$element, '#resources-nav');
|
this.$resourcesNav = this.dom.querySelector(this.$element, '#resources-nav');
|
||||||
|
|
||||||
//decorate option.scrollYOffset to account mobile nav
|
//decorate scrollYOffset to account mobile nav
|
||||||
var origOffset = this.options.scrollYOffset;
|
this.scrollService.scrollYOffset = () => {
|
||||||
this.options.scrollYOffset = () => {
|
|
||||||
let mobileNavOffset = this.$mobileNav.clientHeight;
|
let mobileNavOffset = this.$mobileNav.clientHeight;
|
||||||
return origOffset() + mobileNavOffset;
|
return this.options.scrollYOffset() + mobileNavOffset;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,12 +72,14 @@ export class SideMenu extends BaseComponent {
|
||||||
|
|
||||||
toggleMobileNav() {
|
toggleMobileNav() {
|
||||||
let dom = this.dom;
|
let dom = this.dom;
|
||||||
let $overflowParent = (this.$scrollParent === global) ? dom.defaultDoc().body : this.$scrollParent;
|
let $overflowParent = (this.options.$scrollParent === global) ? dom.defaultDoc().body
|
||||||
|
: this.$scrollParent.$scrollParent;
|
||||||
if (dom.hasStyle(this.$resourcesNav, 'height')) {
|
if (dom.hasStyle(this.$resourcesNav, 'height')) {
|
||||||
dom.removeStyle(this.$resourcesNav, 'height');
|
dom.removeStyle(this.$resourcesNav, 'height');
|
||||||
dom.removeStyle($overflowParent, 'overflow-y');
|
dom.removeStyle($overflowParent, 'overflow-y');
|
||||||
} else {
|
} else {
|
||||||
let viewportHeight = this.$scrollParent.innerHeight || this.$scrollParent.clientHeight;
|
let viewportHeight = this.options.$scrollParent.innerHeight
|
||||||
|
|| this.options.$scrollParent.clientHeight;
|
||||||
let height = viewportHeight - this.$mobileNav.getBoundingClientRect().bottom;
|
let height = viewportHeight - this.$mobileNav.getBoundingClientRect().bottom;
|
||||||
dom.setStyle($overflowParent, 'overflow-y', 'hidden');
|
dom.setStyle($overflowParent, 'overflow-y', 'hidden');
|
||||||
dom.setStyle(this.$resourcesNav, 'height', height + 'px');
|
dom.setStyle(this.$resourcesNav, 'height', height + 'px');
|
||||||
|
|
|
@ -90,7 +90,7 @@ export class MenuService {
|
||||||
this.activeMethodPtr = currentItem.pointer;
|
this.activeMethodPtr = currentItem.pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.changed.next(menu[catIdx], currentItem);
|
this.changed.next({cat: menu[catIdx], item: currentItem});
|
||||||
}
|
}
|
||||||
|
|
||||||
_calcActiveIndexes(offset) {
|
_calcActiveIndexes(offset) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user