click and hold to scroll, touchstart, touchmove, touchend

你离开我真会死。 提交于 2019-12-22 00:34:59

问题


I have a scrollable div. I want people to be able to scroll the list through 'hold', and also select a button for click.

The problem is that when a button is held in order to scroll the div, it is triggering the click function.

I want that do not trigger when scrolling. I need some way to differentiate click of the hold function.

So I'm using:

$('.panel').bind("touchstart mousedown", function (e) {
console.log(e.type);
$(this).addClass('resize');

}).bind("touchmove mousemove", function (e) {
$(this).removeClass('resize');

}).bind("touchend mouseup", function (e) {
$(this).removeClass('resize');
$('.panel').addClass('flip');
});

I thought the following solution.

When '.panel' is mousedown for more than 500 ms, the button activates, pressed:

$(this).addClass('resize');

When '.panel' is mouseup, the button returns to its normal state and then all the buttons make the movement of output:

$(this).removeClass('resize');
 $('.panel').addClass('flip');

BUT if the user mousemove, the mousedown and mouseup actions are canceled.

just do not know how to put this into practice

is something similar to that: http://m.microsoft.com/windowsphone/en-us/demo/default.aspx

Please Suggest.

来源:https://stackoverflow.com/questions/11544948/click-and-hold-to-scroll-touchstart-touchmove-touchend

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!