1

I am using Hammer this way, it works (it just triggers next/prev buttons):

var slider = document.getElementsByClassName('slider');

Hammer(slider[0]).on("swiperight", function() {
    prev.click();
});

A according to Stack thread, on event when modal is coming out (hammer is still swiping behind it :/) I am trying to turn it of with:

Hammer(slider[0]).off("swipeleft");
Hammer(slider[0]).off("swiperight");

But it doesn't work. It's still swipeing behind modal. Any idea why?

Community
  • 1
  • 1
RaV
  • 1,029
  • 1
  • 9
  • 25

1 Answers1

4

Save the Hammer instance to a variable. The following example removes pan event after 5 seconds.

var h = new Hammer(document);
  
h.on('pan', function(){
   console.log('Panned');
});

setTimeout(function(){
    console.log('removed');
    h.off('pan');
}, 5000);
<script src="http://hammerjs.github.io/dist/hammer.min.js"></script>
Adam Azad
  • 11,171
  • 5
  • 29
  • 70