the-glorious-startpage/js/mobile-swipe-callback.js

81 lines
1.7 KiB
JavaScript
Raw Normal View History

2020-06-09 04:02:03 +02:00
class SwipeEventCallbacks extends SwipeEventManager {
constructor() {
super();
this.swipeEvent = this.swipeEvent;
this._createSwipeEvents();
2020-06-04 06:59:50 +02:00
}
2020-06-09 04:02:03 +02:00
// Backgound body swipe callback
_bodyBackgroundSwipeEvent = (el, d) => {
2020-06-04 06:59:50 +02:00
2020-06-09 04:02:03 +02:00
// Swipe left will open dashboard
if (d === 'left') {
dashboard.toggleDashboard();
} else if (d === 'down') {
// Swiping down will open search box
searchBoxShow.toggleSearchBox();
2020-06-09 06:26:02 +02:00
} else if (d === 'right') {
2020-06-09 04:02:03 +02:00
// Swiping right will open web menu
webMenu.toggleWebMenu();
2020-06-09 06:26:02 +02:00
} else if (d === 'up') {
2020-06-09 04:02:03 +02:00
// Swiping up will open weather screen
weatherScreen.toggleWeatherScreen();
}
2020-06-04 06:59:50 +02:00
}
2020-06-09 04:02:03 +02:00
// Dashboard swipe callback
_rightDashboardSwipeEvent = (el, d) => {
2020-06-04 06:59:50 +02:00
2020-06-09 04:02:03 +02:00
// Swipe right will close dashboard
if (d === "right") {
dashboard.toggleDashboard();
}
2020-06-04 06:59:50 +02:00
}
2020-06-09 04:02:03 +02:00
// Blur overlay swipe event
_centeredBoxOverlaySwipeEvent = (el, d) => {
2020-06-04 06:59:50 +02:00
2020-06-09 04:02:03 +02:00
// Swiping up will close search box
if (d === 'up') {
searchBoxShow.toggleSearchBox();
}
2020-06-04 06:59:50 +02:00
}
2020-06-09 04:02:03 +02:00
// Web menu swipe event
_webMenuSwipeEvent = (el, d) => {
// Swiping left will close web menu
2020-06-09 06:26:02 +02:00
if (d === 'left') {
2020-06-09 04:02:03 +02:00
webMenu.toggleWebMenu();
}
}
// Weather screen swipe event
_weatherScreenSwipeEvent = (el, d) => {
// Swiping left will the weather screem
2020-06-09 06:26:02 +02:00
if (d === 'left') {
2020-06-09 04:02:03 +02:00
weatherScreen.toggleWeatherScreen();
}
}
// Assign swipe callback for each IDs
_createSwipeEvents = () => {
this.swipeEvent('bodyBackground', this._bodyBackgroundSwipeEvent);
this.swipeEvent('rightDashboard', this._rightDashboardSwipeEvent);
this.swipeEvent('centeredBoxOverlay', this._centeredBoxOverlaySwipeEvent);
this.swipeEvent('webMenu', this._webMenuSwipeEvent);
2020-06-04 06:59:50 +02:00
2020-06-09 04:02:03 +02:00
this.swipeEvent('weatherScreen', this._weatherScreenSwipeEvent);
2020-06-04 06:59:50 +02:00
}
}