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. 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/. However I have noticed that the mouse interaction for scrolling the map does not work on FireFox or on an iPod. It looks like iPod may use different events (ontouch etc) according to Native HTML5 Drag and Drop in Mobile Safari (iPad, iPod, iPhone)?. And that doesn't explain why FireFox wouldn't react. 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?
Asked
Active
Viewed 522 times
1 Answers
1
you need to correctly retrieve your srcElement
var srcEl = e.srcElement? e.srcElement : e.target;
try it
P.S.: see targets

Irishka
- 1,136
- 6
- 12
-
1also check your event: e= e || window.event; – Irishka Oct 24 '11 at 12:57
-
I've updated the code, and it still doesn't seem to be working in FireFox. – BlueMonkMN Oct 25 '11 at 02:47
-
1I think your script generally is written without cross browser compatibility, e.g. for making events work in other browsers than IE you need to use addEventListener instead of assigning a function to element.onEventName property, and so on.. why you do not use some js framework e.g. jQuery? it does take care of browser compatibility for you – Irishka Oct 25 '11 at 07:32
-
1or you are using offsetX - this wont work in FF either, http://www.quirksmode.org/dom/w3c_cssom.html#offsetX – Irishka Oct 25 '11 at 07:47
-
Since this code is being generated, it seems clumsy to require a third party framework to make it work, especially for such a small thing as hooking up these few events. I don't need a whole framework for that. I just need to do it in a cross-platform-compatible way. It works on both IE and Chrome, so I thought I was close. But it's been a long time since I had to get into the browser wars so I've probably forgotten (or never learned) many of the significant differences between browsers. – BlueMonkMN Oct 25 '11 at 13:12
-
unfortunately it's still an issue :( – Irishka Oct 25 '11 at 13:23
-
According to http://www.quirksmode.org/js/events_access.html I shouldn't need to use addEventListener for cross-browser compatibility. – BlueMonkMN Oct 25 '11 at 13:24
-
Once I switched to clientX and clientY instead of offsetX and offsetY, things started working in FireFox. – BlueMonkMN Oct 29 '11 at 14:13