-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
18 lines (17 loc) · 817 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module.exports = function(callback) {
// PUBLIC
this.isLandscape = () => window.innerWidth > window.innerHeight;
// bottom bar is shown in portrait when documentElement client height is
// equal to window innerHeight. cf. http://ryanve.com/lab/dimensions/
this.getBottomBarVisibility = () => !this.isLandscape() && document.documentElement.clientHeight === window.innerHeight;
this.destroy = () => window.removeEventListener('resize', listener);
// PRIVATE
let bottomBarVisible = this.getBottomBarVisibility();
const listener = window.addEventListener('resize', event => {
// invoke callback if bottom bar visibility has changed
if (bottomBarVisible !== this.getBottomBarVisibility()) {
bottomBarVisible = this.getBottomBarVisibility();
callback(bottomBarVisible);
}
});
}