JavaScript mapping touch events to mouse events

I'm using the YUI slider that operates with mouse move events. I want to make it respond to touchmove events (iPhone and Android). How can I produce a mouse move event when a touchmove event occurs? I'm hoping that just by adding some script at the top that touchmove events will get mapped to the mouse move events and I won't have to change anything with the slider. I am sure thi

JavaScript将触摸事件映射到鼠标事件

我正在使用YUI滑块来操作鼠标移动事件。 我想让它响应touchmove事件(iPhone和Android)。 触摸移动事件发生时,如何产生鼠标移动事件? 我希望只需在顶部添加一些脚本,touchmove事件就会映射到鼠标移动事件上,而不必用滑块来更改任何内容。 我相信这是你想要的: function touchHandler(event) { var touches = event.changedTouches, first = touches[0], type = ""; switch(event.type) {

Phonegap mobile app tapping while scrolling selects incorrect item

I have a hybrid mobile app developed with phone gap and targeted for iOS only devices. I use Backbone.js as my MVC framework, jQuery, FastClick.js and Hammer.js for events. I have a list of items which is vertically scrollable. If I tap on an item, it should open the details view. This works fine if I tap on the item when the list is not scrolling. But if I tap on an item while the list is s

PhoneGap移动应用程序在滚动时点击选择不正确的项目

我有一个混合移动应用程序,开发了手机差距,并针对iOS设备。 我使用Backbone.js作为我的MVC框架,jQuery,FastClick.js和Hammer.js来处理事件。 我有一个可垂直滚动的项目列表。 如果我点击一个项目,它应该打开细节视图。 如果我在列表不滚动时点击该项目,这工作正常。 但是,如果在列表滚动或减速时点击某个项目,则会选择错误的项目并显示其详细信息。 我看着在滚动列表上点击会产生错误元素的tap事件,用于iPhone /

Scroll event doesn't fire unless page moves

I'm looking to get an event to fire when one scrolls "up" from $(window).scrollTop == 0 . If you have the following code: $(window).scroll(function(){ console.log("scrolling") }); On a page where the document < window height then that event never fires because $(window).scrollTop isn't changing, but this doesn't mean that there's no mouse scroll input. I want

除非页面移动,否则滚动事件不会触发

当我从$(window).scrollTop == 0滚动“向上”时,我正在寻找一个触发事件。 如果您有以下代码: $(window).scroll(function(){ console.log("scrolling") }); 在文档<窗口高度的页面上,该事件从不触发,因为$(window).scrollTop没有更改,但这并不意味着没有鼠标滚动输入。 无论页面是否在移动,我都希望事件在鼠标滚动时触发。 看起来像你在找什么: http://jsfiddle.net/n8eVQ/ $(document).on('mousewheel DOM

Understanding touch events

I'm trying to make some of my libraries work with touch devices, but I'm having a hard time trying to figure out how they're supported and how they work. Basically, there are 5 touch events, but it seems there's consensus among mobile browsers only on the touchstart event (duh). I've created a fiddle as a test case. I've tested this on my Galaxy Note with Android 4 on

了解触摸事件

我试图让我的一些图书馆能够使用触摸设备,但我很难弄清楚它们是如何得到支持以及它们是如何工作的。 基本上,有5个触摸事件,但似乎移动浏览器只在touchstart事件( touchstart )上达成共识。 我创建了一个小提琴作为测试用例。 我已经在Galaxy Note上使用Android 4在我的Galaxy Note上进行了测试,但您也可以通过桌面浏览器检查链接。 目标是设法弄清楚如何处理水龙头,双击和长时间水龙头。 没有什么花哨。 基本上

How can I monitor scroll position while scrolling in Safari on iOS?

I currently use $(window).bind('scroll', foo); to monitor $(window).scrollTop() and do stuff to create a parallax effect. In all desktop browsers foo() is called for each pixel the user scrolls, and everything is nice and dandy. In Safari on iOS, the scroll event is only fired AFTER the scrolling is finished. I added $(window).bind('touchmove', foo); to make sure the functi

如何在iOS上的Safari中滚动时监视滚动位置?

我目前使用$(window).bind('scroll', foo); 监视$(window).scrollTop()并做些东西来创建视差效果。 在所有的桌面浏览器中,用户滚动的每个像素都会调用foo(),并且所有内容都很漂亮和华丽。 在iOS上的Safari上,滚动事件仅在滚动完成后才会触发。 我添加了$(window).bind('touchmove', foo); 以确保在iOS中的滑动过程中调用该函数,并且让我进一步了一点。 当用户释放手指时,页面继续滚动,但事

Pointermove does not fire for touch on IE

I want to listen to pointermove event on IE11, but it seems that pointermove only fires for mouse (and possibly pen), but not when you are using your finger. http://jsfiddle.net/qq2hjL2g/ Actually, the specification says that it fires for pens/mice, so this may not be really a bug. But, is there any way to listen to pointermove on IE for touch? There must be, but I was very surprised to se

Pointermove不会因触摸IE而触发

我想在IE11上听pointermove事件,但是似乎pointermove只会触发鼠标(可能是笔),但不会在使用手指时触发。 http://jsfiddle.net/qq2hjL2g/ 实际上,规范说明它会触发笔/鼠标,所以这可能不是真正的错误。 但是,有没有什么方法可以在IE上进行点触式触摸? 必须有,但是我非常惊讶地发现pointermove根本没有开火。 编辑:我发现,如果我把CSS touch-action: none在div上,pointermove事件触发。 但为什么? 我试图找

Touch event for mouseover

In a web application touch-version, I'm converting mouse events to touch events. mousedown=>touchstart, mouseup=>touchend... I also want to convert mouseover event. Touch mouseover ? it is ansurd, the touchpad doesnt detect your finger in the air ! Not really, if you swipe your finger over an element, eg And you want the element to get bigger... for example. Is there a touch e

触摸鼠标悬停的事件

在Web应用程序触摸版本中,我将鼠标事件转换为触摸事件。 mousedown => touchstart,mouseup => touchend ... 我也想转换鼠标悬停事件。 触摸鼠标悬停? 它是答案,触摸板不检测你的手指在空气中! 不是真的,如果你在一个元素上滑动手指,例如你想要元素变得更大......例如。 是否有这种行为的触摸事件(鼠标悬停触摸)? 目前,jQuery UI用户界面库不支持在其小部件和交互中使用触摸事件。 这意味着您在桌

touchend is not triggered

I have implemented touchevents which evoke the same function like my mouse events: onclick -> the touchstart { do something } mousemover -> touchmove { do something } mouseup -> touchend { do something } All works but touchend is not triggered. document.body.addEventListener('touchstart', start); function start(e){ do something ; touchDefaults(e); } docu

touchend没有被触发

我已经实现了touchevents,它引发了与我的鼠标事件相同的功能: onclick - > touchstart {做点事情} mousemover - > touchmove {做点什么} mouseup - > touchend {do something} 所有作品,但touchend没有触发。 document.body.addEventListener('touchstart', start); function start(e){ do something ; touchDefaults(e); } document.body.addEventListener('touchmove', move

Two pages grabbing click event on iPad

I have a website I have written which is cross platform. On the iPad I have to use the mouseup and mouseup events to simulate a click (because it is events imbedded within SVG inside an iFrame and there are special events if someone presses and holds, or presses and drags or presses and releases (clicks)) Here is what is happening. touchStart event triggered. touchEnd event triggered. My sc

iPad上有两个页面抓取点击事件

我有一个我写的是跨平台的网站。 在iPad上,我必须使用mouseup和mouseup事件来模拟点击(因为它是嵌入在iFrame中的SVG内的事件,并且如果有人按下并按住或拖动或按下并释放(点击),则会出现特殊事件) 这是发生了什么事。 触发touchStart事件。 touchEnd事件触发。 我的脚本发现这是一个单击事件,然后触发以下事件: window.parent.window.location.href =“../TRL/SelectHotspot.aspx”+ returnString 浏览器然后进

touch events stop firing when dragging down on mobile Safari

When i add event listeners to account for touch events such as touchmove and touchstart document.addEventListener("touchstart", function(event){ event.preventDefault(); document.getElementById("fpsCounter").innerHTML = "touch start"; trace("touch start"); }, false); document.addEventListener("touchmove", function(event){ eve

触摸事件在移动Safari上拖动时停止触发

当我添加事件监听器来解释触摸事件,如touchmove和touchstart document.addEventListener("touchstart", function(event){ event.preventDefault(); document.getElementById("fpsCounter").innerHTML = "touch start"; trace("touch start"); }, false); document.addEventListener("touchmove", function(event){ event.preventDefault();