Skip to content

Commit

Permalink
#90 fix not worked enableBodyScroll in some conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Curic committed Jan 28, 2019
1 parent 0e65e5f commit 3eae730
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
6 changes: 4 additions & 2 deletions lib/bodyScrollLock.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,13 @@ export const enableBodyScroll = targetElement => {
documentListenerAdded = false;
}
} else if (locks.length === 1 && locks[0].targetElement === targetElement) {
restoreOverflowSetting();

locks = [];
} else {
locks = locks.filter(lock => lock.targetElement !== targetElement);
}

if (!locks.length) {
restoreOverflowSetting();
}
};

6 changes: 4 additions & 2 deletions lib/bodyScrollLock.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,16 @@
documentListenerAdded = false;
}
} else if (locks.length === 1 && locks[0].targetElement === targetElement) {
restoreOverflowSetting();

locks = [];
} else {
locks = locks.filter(function (lock) {
return lock.targetElement !== targetElement;
});
}

if (!locks.length) {
restoreOverflowSetting();
}
};
});

2 changes: 1 addition & 1 deletion lib/bodyScrollLock.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/bodyScrollLock.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,12 @@ export const enableBodyScroll = (targetElement: any): void => {
documentListenerAdded = false;
}
} else if (locks.length === 1 && locks[0].targetElement === targetElement) {
restoreOverflowSetting();

locks = [];
} else {
locks = locks.filter(lock => lock.targetElement !== targetElement);
}

if (!locks.length) {
restoreOverflowSetting();
}
};

0 comments on commit 3eae730

Please sign in to comment.