简体   繁体   English

如何确定不同mouseDown函数的触发顺序

[英]How to decide the triggering order of different mouseDown function

I have two kinds of functions which will detect the mousedown event and trigger some functions. 我有两种功能可以检测mousedown事件并触发一些功能。

  1. window.onmousedown = function(...)

  2. Raphael object:
    var rec = paper.rect(10,10,10,10)
    rec.mousedown(...)

the second one is a rectangle create by Raphael.js and the function will be triggered when you click the rectangle. 第二个是Raphael.js创建的矩形,当您单击该矩形时将触发该函数。

I need the second one to be triggered before the first one, but it seems that the order of triggering of the two functions is randomly decided by the browser? 我需要在第一个触发之前触发第二个触发,但是似乎两个功能的触发顺序是由浏览器随机确定的吗?

Do I have any way to control it !? 我有什么办法控制它!

thanks!! 谢谢!!

I need the second one to be triggered before the first one 我需要先触发第二个


Look at the DEMO , mousedown even triggers on circle before window's . 看一下DEMOmousedown甚至在window's之前window's circle触发。

 window.onmousedown = function() { alert('Yes'); } var paper = new Raphael(document.getElementById('paper'),500,400); var circle = paper.circle(100,100,50).attr({fill:'orange', stroke:'green', 'stroke-width':3}); circle.mousedown(function() { alert('No'); this.attr({fill:'green', stroke:'red', 'stroke-width':3}); }); circle.mouseout(function() { this.attr({fill:'orange', stroke:'green', 'stroke-width':3}); }); 

Click on the circle and see that the alerts . 单击圆圈,查看alerts Good luck 祝好运

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

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