Pergunta

I am working with hammer.js and now I want to change the width of an element by using the touch x-axis distance:

var swipeEvent = Hammer(element).on( 'touch' , function (event) {
        console.log("x: " + event.gesture.startEvent.touches[0].deltaX);

        var curWidth = $('#box-id').css('width');
        console.log("swipe!!    :" + curWidth);
        $('#box-id').css('width', curWidth + curWidth);
    }   
  );

Now of cource the problem is the the code is only execute once at the event. How do I run some logic always changing the width while the touch has not ended? is this possible with hammer.js?

Foi útil?

Solução

You might be looking for the drag event, which gets fired continuously as you drag your finger, instead of touch:

https://github.com/EightMedia/hammer.js/wiki/Getting-Started#gesture-events

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top