如何在jQuery Mobile中缩放pinchIn / pinchOut?

时间:2014-09-19 10:35:01

标签: jquery jquery-mobile

我写过这些事件。我没有得到如何以编程方式pinchIn pinchOut。请帮我。我正在使用TouchSwipe插件。我试过了:

pinchIn: function(event, direction, distance, duration, fingerCount, pinchZoom) {
    console.log('pinchIn');
    $(this).css('zoom','1.5');        
},
pinchOut:function(event, direction, distance, duration, fingerCount, pinchZoom) {
    $(this).css('zoom','1.0');
    console.log('pinchOut');         
},

1 个答案:

答案 0 :(得分:1)

这是因为您正在设置css()函数以每次放大静态量。每次触发事件时都应该添加某种增量,这样就可以放大"进一步"每一次。这是一个非常简单的例子:

http://jsfiddle.net/x4gkoeos/

所以例如

var pinchAmount = 0; // not sure what you'd set this to for your use case

pinchIn: function(event, direction, distance, duration, fingerCount, pinchZoom) {
    console.log('pinchIn');
    $(this).css('zoom', pinchAmount);    
    pinchAmount = pinchAmount + 1 // Or whatever you want the increment to be, I'm guessing 1
}