forked from extern/the-glorious-startpage
add mobile swipe callback js
This commit is contained in:
parent
afb1f6d116
commit
21d8aefa3d
@ -231,7 +231,7 @@
|
|||||||
<script src="js/weather-screen.js"></script>
|
<script src="js/weather-screen.js"></script>
|
||||||
<script src="js/weather-settings.js"></script>
|
<script src="js/weather-settings.js"></script>
|
||||||
<script src="js/web-menu.js"></script>
|
<script src="js/web-menu.js"></script>
|
||||||
|
|
||||||
<script src="js/mobile-swipe-event.js"></script>
|
<script src="js/mobile-swipe-event.js"></script>
|
||||||
|
<script src="js/mobile-swipe-callback.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
65
js/mobile-swipe-callback.js
Normal file
65
js/mobile-swipe-callback.js
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
// 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);
|
@ -155,11 +155,11 @@ webMenuSearchBox.onkeydown = (event) => {
|
|||||||
webItemFocus.callback();
|
webItemFocus.callback();
|
||||||
|
|
||||||
// Hide web menu
|
// Hide web menu
|
||||||
// webMenuToggle();
|
toggleWebMenu();
|
||||||
|
|
||||||
} else if (event.key === 'Backspace' && webMenuSearchBox.value.length < 1) {
|
} else if (event.key === 'Backspace' && webMenuSearchBox.value.length < 1) {
|
||||||
// Hide web menu if backspace is pressed and searchbox value is 0
|
// Hide web menu if backspace is pressed and searchbox value is 0
|
||||||
// webMenuToggle();
|
toggleWebMenu();
|
||||||
|
|
||||||
} else if ((event.key === 'Escape') || (event.key === 'Alt')) {
|
} else if ((event.key === 'Escape') || (event.key === 'Alt')) {
|
||||||
// Ignore escape and alt key
|
// Ignore escape and alt key
|
||||||
|
Loading…
Reference in New Issue
Block a user