-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mouseleave & mouseenter fired twice #367
Comments
oh, and not to mention, mouseenter & mouseleave do not behave in gwtquery like specified in jquery or elsewhere. Please take a look at http://api.jquery.com/mouseover/ |
Please explain a bit more what you mean by :
|
it should trigger only once as long you're within the node tree of the event holder. I have this simple example: <style>
<!--
.test-box1 {
position:relative;
display:block;
width:300px;
height:300px;
background:white;
}
.test-box2 {
position:absolute;
display:block;
top:0;right:50px;bottom:50px;left:0px;
background:blue;
opacity:0.5;
}
.test-box3 {
display:block;
width:100px;
height:100px;
background:yellow;
}
-->
</style>
<div id="testbox" class="test-box1">
<a href="javascript:;" class="test-box2">
<span class="test-box3"></span>
</a>
</div> final Element testElm = $("#testbox").get(0);
$(testElm).on("mouseenter", new Function() {
public boolean f(Event event, Object... obj) {
Console.log("mouseenter");
return true;
}
})
.on("mouseleave", new Function() {
public boolean f(Event event, Object... obj) {
Console.log("mouseleave");
return true;
}
}); |
looks like the event is bound once as "mouseenter" and once again as "mouseover".. |
As I found out the cause if this bug, I could create a workaround as long this bug exists. $(testElm).on("mouseenter", new Function() {
public boolean f(Event event, Object... obj) {
if (!event.getType().equals("mouseenter") || JsEventHelper.eventTriggeredByChilds(event)) {
return true;
}
QuickHelper.consoleLog("MOUSEENTER");
return true;
}
})
.on("mouseleave", new Function() {
public boolean f(Event event, Object... obj) {
if (!event.getType().equals("mouseleave") || JsEventHelper.eventTriggeredByChilds(event)) {
return true;
}
QuickHelper.consoleLog("MOUSELEAVE");
return true;
}
}); Content of JsEventHelper.eventTriggeredByChilds(event): public static final boolean eventTriggeredByChilds(Event event) {
Element eventTarget = event.getCurrentEventTarget().cast();
Element currentTarget = event.getEventTarget().cast();
return GQuery.contains(eventTarget, currentTarget);
} Note: event.getType().equals("mouseleave"); To prevent further execution as gwtquery is trying to execute it once again as "mouseover". Now it seems to work as intended. |
Thanks! We'll look into this. |
the events "mouseleave" and "mouseenter" are fired twice.
mouseout & mouseover are called just once as expected.
The text was updated successfully, but these errors were encountered: