fix mobile nav

This commit is contained in:
Roman Hotsiy 2016-05-17 19:38:12 +03:00
parent 547cf0ceab
commit 7380f89482
2 changed files with 10 additions and 9 deletions

View File

@ -31,10 +31,10 @@ export class SideMenu extends BaseComponent {
this.options = optionsService.options;
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.activeItemCaption = item && item.summary || '';
@ -54,11 +54,10 @@ export class SideMenu extends BaseComponent {
this.$mobileNav = this.dom.querySelector(this.$element, '.mobile-nav');
this.$resourcesNav = this.dom.querySelector(this.$element, '#resources-nav');
//decorate option.scrollYOffset to account mobile nav
var origOffset = this.options.scrollYOffset;
this.options.scrollYOffset = () => {
//decorate scrollYOffset to account mobile nav
this.scrollService.scrollYOffset = () => {
let mobileNavOffset = this.$mobileNav.clientHeight;
return origOffset() + mobileNavOffset;
return this.options.scrollYOffset() + mobileNavOffset;
};
}
@ -73,12 +72,14 @@ export class SideMenu extends BaseComponent {
toggleMobileNav() {
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')) {
dom.removeStyle(this.$resourcesNav, 'height');
dom.removeStyle($overflowParent, 'overflow-y');
} 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;
dom.setStyle($overflowParent, 'overflow-y', 'hidden');
dom.setStyle(this.$resourcesNav, 'height', height + 'px');

View File

@ -90,7 +90,7 @@ export class MenuService {
this.activeMethodPtr = currentItem.pointer;
}
this.changed.next(menu[catIdx], currentItem);
this.changed.next({cat: menu[catIdx], item: currentItem});
}
_calcActiveIndexes(offset) {