在JavaScript中用鼠标模拟滑动 [英] Simulate swipe with mouse in javascript

查看:393
本文介绍了在JavaScript中用鼠标模拟滑动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使图像旋转器能够通过滑动导航在移动设备上运行.我还试图使同一个旋转器在PC浏览器上工作,但能够使用鼠标拖动来模拟滑动. 有什么好主意吗?

I'm trying to make an image rotator that works on mobile devices using swipe for navigation. I'm also trying to make the same rotator to work on PC browsers but to be able to use the mouse drag to simulate swipe. Any good ideeas?

推荐答案

您将要处理onmousedownonmousemoveonmouseup事件,跟踪鼠标的位置并相应地操纵图像旋转器.

You'll want to handle onmousedown, onmousemove, and onmouseup events, keeping track of the mouse position and manipulating your image rotator accordingly.

这篇关于在JavaScript中用鼠标模拟滑动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆