// 元素移动
let icon_right_lottry = document.querySelector("拖动对象"),lottry_l,lottry_t,lottry_x,lottry_y,touchstartTime = 0,touchstartInterval;
icon_right_lottry.addEventListener("touchstart",function(e){
e.preventDefault();
lottry_l = $("拖动对象").css("left").split("px")[0];
lottry_t = $("拖动对象").css("top").split("px")[0];
lottry_x = e.touches[0].pageX;
lottry_y = e.touches[0].pageY;
touchstartInterval = setInterval(() => {
touchstartTime++;
}, 100);
});
icon_right_lottry.addEventListener("touchmove", function (event){
event.preventDefault();
let endx = event.touches[0].pageX - lottry_x + lottry_l * 1;
let endy = event.touches[0].pageY - lottry_y + lottry_t * 1;
//活动区域的最小值
if(endy < 37){
endy = 37;
}
//活动区域的最大值
if(endy > 200){
endy = 200;
}
$("拖动对象").css({
"left":`${endx}px`,
"top":`${endy}px`
});
});
icon_right_lottry.addEventListener("touchend", function (e){
e.preventDefault();
clearInterval(touchstartInterval);
if(touchstartTime < 3){
识别单纯点击的情况处理
}
touchstartTime = 0;
});
h5--可在规定范围内拖动元素
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 值 描述url需使用的自定义光标的 URL。 注释:请在此列表的末端始终定义一种普通的光标,以防没有由 URL...