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

65 lines
1.3 KiB
JavaScript
Raw Normal View History

2020-06-04 06:59:50 +02:00
// Swipe Callbacks
// Backgound body swipe callback
const bodyBackgroundSwipeEvent = (el, d) => {
// Swipe left will open dashboard
if (d === 'left') {
toggleDashboard();
} else if (d === 'down') {
// Swiping down will open search box
toggleSearchBox();
} else if (d == 'right') {
// Swiping right will open web menu
toggleWebMenu();
} else if (d == 'up') {
// Swiping up will open weather screen
toggleWeatherScreen();
}
}
// Dashboard swipe callback
const rightDashboardSwipeEvent = (el, d) => {
// Swipe right will close dashboard
if (d === "right") {
toggleDashboard();
}
}
// Blur overlay swipe event
const centeredBoxOverlaySwipeEvent = (el, d) => {
// Swiping up will close search box
if (d === 'up') {
toggleSearchBox();
}
}
// Web menu swipe event
const webMenuSwipeEvent = (el, d) => {
// Swiping left will close web menu
if (d == 'left') {
toggleWebMenu();
}
}
// Weather screen swipe event
const weatherScreenSwipeEvent = (el, d) => {
// Swiping left will the weather screem
if (d == 'left') {
toggleWeatherScreen();
}
}
swipeEvent('bodyBackground', bodyBackgroundSwipeEvent);
swipeEvent('rightDashboard', rightDashboardSwipeEvent);
swipeEvent('centeredBoxOverlay', centeredBoxOverlaySwipeEvent);
swipeEvent('webMenu', webMenuSwipeEvent);
swipeEvent('weatherScreen', weatherScreenSwipeEvent);