简体   繁体   English

使用Jquery或Jquery Mobile中的左侧滑动向左旋转图像

[英]Rotate image left using swipe left in Jquery or Jquery Mobile

I done my almost some functionality In my app .I done animation on tabhold and vmouseup on removing the mouse.But I need to shift only one image at one time left and right while using swipeleft or swipe right.But my image rotate only in right not in left side. 我在我的应用程序中完成了几乎所有的功能。我在tabholdvmouseup上完成了移除鼠标的动画。 但是我需要在使用向左或向右滑动的同时左右移动一个图像。但是我的图像仅在右侧旋转不在左侧。 Can you please tell me how to rotate image. 你能告诉我如何旋转图像吗? Link findle: http://jsfiddle.net/PMrDn/101/ 链接findle: http//jsfiddle.net/PMrDn/101/

$(document).off('swipeleft').on('swipeleft', '#index', function(event){    
        timerObject.interval_id = setInterval(animate, 20);
    });

    $(document).off('swiperight').on('swiperight', '#index', function(event){   
        timerObject.interval_id = setInterval(animate, 20);           
    }); 

You are using the same function (animate) when swiping left or right. 向左或向右滑动时使用相同的功能(动画)。 You can use a different function for each functionality or you can pass some parameters to specify left or right turning. 您可以为每个功能使用不同的功能,也可以传递一些参数来指定左转或右转。

If you change boxes[idx].currentAngle--; 如果你更改boxes[idx].currentAngle--;

to boxes[idx].currentAngle++; to boxes[idx].currentAngle++;

the items turn left 物品向左转

You are calling animate() for both cases, but animate() only rotates to the right ( boxes[idx].currentAngle--; ). 您正在为两种情况调用animate(),但animate()仅向右旋转( boxes[idx].currentAngle--; )。 You could pass the angle difference to animate() instead of always subtracting 1. Example: http://jsfiddle.net/PMrDn/102/ 您可以将角度差传递给animate(),而不是总是减去1.示例: http//jsfiddle.net/PMrDn/102/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM