dalekjs / dalek

[unmaintained] DalekJS Base framework
MIT License
695 stars 63 forks source link

Feature request: Trigger an unbound click event #120

Open krnlde opened 10 years ago

krnlde commented 10 years ago

Scenario: I have a modal window that blocks all interactions below its backdrop. If you now .click() an element under the backdrop with Dalek it'll resolve the assertion to true, which is wrong since a real customer would click either the modal backdrop or the modal itself instead of the underlying element.

Therefore, an awesome feature would be to provide an element-unbound .click(x, y) with the x and y positions of the virtual cursor. Basically the idea is to always click the upper element visible at a given point.

Alternatively you could abstract the x, y behaviour per default, in a way that it always requests the selectors $('.context').offset(), adds some pixels and then clicks the position, no matter what's underlying really.

Alternatively.... one could somehow ask for intersecting elements and then automatically resolve to false since some parts of the area wouldn't be clickable. But that seems kinda unpractical to me.

Happy hacking

krnlde commented 10 years ago

document.elementFromPoint might be somewhat helpful. Maybe this method should be called 4 times to reach all 4 corners and determine whether the context element is at least intersected. Seems my last suggested "alternative" is not so unpractical at all, but yet very useful.

btw. this works even down to IE5.5

asciidisco commented 10 years ago

Really interesting feature request. I think we should discuss adding this as a plugin as soon as we reached that point with Skaro. @rodneyrehm Do you agree?