Merge pull request #2407 from SergioCrisostomo/fix-look-for-parent

don't check past document.body when moving up DOM tree
This commit is contained in:
Aresn 2017-11-13 19:24:20 -06:00 committed by GitHub
commit 1d15cbbced
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -239,8 +239,8 @@
if (!currentOffset) return; if (!currentOffset) return;
let newOffset = currentOffset > containerWidth let newOffset = currentOffset > containerWidth
? currentOffset - containerWidth ? currentOffset - containerWidth
: 0; : 0;
this.setOffset(newOffset); this.setOffset(newOffset);
}, },
@ -251,16 +251,16 @@
if (navWidth - currentOffset <= containerWidth) return; if (navWidth - currentOffset <= containerWidth) return;
let newOffset = navWidth - currentOffset > containerWidth * 2 let newOffset = navWidth - currentOffset > containerWidth * 2
? currentOffset + containerWidth ? currentOffset + containerWidth
: (navWidth - containerWidth); : (navWidth - containerWidth);
this.setOffset(newOffset); this.setOffset(newOffset);
}, },
getCurrentScrollOffset() { getCurrentScrollOffset() {
const { navStyle } = this; const { navStyle } = this;
return navStyle.transform return navStyle.transform
? Number(navStyle.transform.match(/translateX\(-(\d+(\.\d+)*)px\)/)[1]) ? Number(navStyle.transform.match(/translateX\(-(\d+(\.\d+)*)px\)/)[1])
: 0; : 0;
}, },
setOffset(value) { setOffset(value) {
this.navStyle.transform = `translateX(-${value}px)`; this.navStyle.transform = `translateX(-${value}px)`;
@ -313,7 +313,7 @@
}, },
isInsideHiddenElement () { isInsideHiddenElement () {
let parentNode = this.$el.parentNode; let parentNode = this.$el.parentNode;
while(parentNode) { while(parentNode && parentNode !== document.body) {
if (parentNode.style.display === 'none') { if (parentNode.style.display === 'none') {
return parentNode; return parentNode;
} }