0

I was wondering if you can assign an event listener on a certain part of a mobile phone screen? For example just 90% of the screen only. I have an bottle that will spin regarding of the direction of the swipe. I have a button on the bottom of the screen that when is clicked, will go back two pages. However, when I click the button, the "click" is not triggered, instead the eventlistener is always triggered. This is an Augmented Reality App and I use Wikitude and Phonegap for the app. Thanks.

4

1 回答 1

0

Events are associated with DOM objects (tags). So if you have an onmousedown listener on an img tag, it will handle any and all mousedown events that happen on that img. There is no way to tell it to only listen to, say, the left half of that img.

In your case, you will probably want to place a div that covers the 90% of your screen that you want to make active, and attach your event listeners to that div instead of the document. That's the easiest solution. Would it work for you?

于 2014-09-05T11:31:20.153 回答