简体   繁体   English

对FireFox和iPod上的HTML5鼠标事件做出反应(Safari?)

[英]React to HTML5 mouse events on FireFox and iPod (Safari?)

I am updating my scrolling game engine to output HTML5 code for the scrolling maps it generates, so that it can be used not only as a (somewhat-platform-specific) complete game creator, but also as a cross-platform HTML5 scrolling map editor. 我正在更新滚动游戏引擎 ,以为其生成的滚动地图输出HTML5代码,以便它不仅可以用作(某种程度上特定于平台的)完整游戏创建者,还可以用作跨平台HTML5滚动地图编辑器。 I got past the challenge of supporting the graphic tinting as described in my earlier question . 我克服了前面的问题中所述的支持图形着色的挑战。 And I have a nice sample running at http://sgdk2.enigmadream.com/ben/ . 我在http://sgdk2.enigmadream.com/ben/上运行了一个不错的示例。 However I have noticed that the mouse interaction for scrolling the map does not work on FireFox or on an iPod. 但是,我注意到,用于滚动地图的鼠标交互在FireFox或iPod上不起作用。 It looks like iPod may use different events (ontouch etc) according to Native HTML5 Drag and Drop in Mobile Safari (iPad, iPod, iPhone)? 根据移动Safari(iPad,iPod,iPhone)中的Native HTML5拖放,看来iPod可能会使用不同的事件(ontouch等)? . And that doesn't explain why FireFox wouldn't react. 但这并不能解释为什么FireFox不会做出反应。 Isn't there a more universal way to support mouse or touch interaction? 是否存在更通用的方式来支持鼠标触摸交互? Do the touch events also work for mouse, or are they specific to touch? 触摸事件是否也适用于鼠标,或者它们特定于触摸? How would you recommend interacting with this scrolling map in the most cross-platform compatible way? 您如何建议以最跨平台兼容的方式与此滚动地图进行交互?

you need to correctly retrieve your srcElement 您需要正确检索您的srcElement

var srcEl = e.srcElement? e.srcElement : e.target; 

try it 试试吧

PS: see targets PS:查看目标

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

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