import Hammer from 'hammerjs';
$w.onReady(function () {
var myElement = document.body;
var hammertime = new Hammer(myElement);
hammertime.get('swipe').set({ direction: Hammer.DIRECTION_ALL });
hammertime.on('swipe', function(ev) {
if (ev.direction == Hammer.DIRECTION_LEFT) {
var nextPage = getNextPage();
if (nextPage !== null) {
wixLocation.to(nextPage);
}
}
if (ev.direction == Hammer.DIRECTION_RIGHT) {
var prevPage = getPrevPage();
if (prevPage !== null) {
wixLocation.to(prevPage);
}
}
});
function getNextPage() {
var currentPageUrl = wixLocation.path;
var pages = ['app-start', 'app-servizi', 'app-prenota', 'ordina-farmaco', 'app-ricetta', 'app-prodotto', 'app-consigli', 'app-per-te', 'app-utility', 'app-modulo', 'app-info'];
var currentIndex = pages.indexOf(currentPageUrl);
if (currentIndex === -1 || currentIndex === pages.length - 1) {
return null;
}
return '/' + pages[currentIndex + 1].replace(/ /g, '-').toLowerCase();
}
function getPrevPage() {
var currentPageUrl = wixLocation.path;
var pages = ['app-start', 'app-servizi', 'app-prenota', 'ordina-farmaco', 'app-ricetta', 'app-prodotto', 'app-consigli', 'app-per-te', 'app-utility', 'app-modulo', 'app-info'];
var currentIndex = pages.indexOf(currentPageUrl);
if (currentIndex <= 0) {
return null;
}
return '/' + pages[currentIndex - 1].replace(/ /g, '-').toLowerCase();
}
});
top of page
bottom of page