Languages

Menu
Sites
Language
Swipe event triggering twice

Hi,

I am building a web app that uses the tau page system, each page has a swipe gesture event attached to it but they get triggered twice.

I can't actually find any examples of using the page system with swiping, is it not the right way??

here's my code:

function mainSwipeEvent(e){
    console.log("Main Page Swiped");
    if (e.detail.direction == "left") {
        tau.changePage('#info');
    }
    if (e.detail.direction == "right") {
        tau.changePage('#settings');
    }
}
tau.event.enableGesture(mainPage, new tau.event.gesture.Swipe({
        orientation: "horizontal"
	}));
mainPage.addEventListener("swipe", function (e) {mainSwipeEvent(e);});

This is driving me crazy, so any help would be appreciated.

Duncan

Responses

2 Replies
Anh Nguyen

Hi Duncan,

Could you try to removeEventListener whenever leaving the page? Just guess but the eventListener might be added twice.

Duncan Wood

Hi Ahn, Yes I've tried both adding/removing when page visible and static version but both trigger twice.

I've had to switch to sectionchanger which isnt ideal but I've made it work.

Tnx.