JavaScript中的自定义事件 [英] Custom Event in JavaScript
问题描述
好的。
我基本上想要一个像
onElementClose这样的事件
当另一个div / block / element进来时,它基本会触发一个函数它周围的某个区域(例如5px)。
我确信自定义事件是可能的,我见过很多奇怪的例子。
所以除非你100%肯定这是不可能的,请不要说它是不可能的。
a setInterval检查周围是否有一个元素这么长时间是不可接受的。因为将有数百个元素使用此活动。
如果我没有足够清楚地解释这个,请询问
谢谢,Josh。
元素将如何接近,即它们是否会从原始位置移开,或者是否会创建可能接近已存在元素的新元素?
从它们的原始位置移动,元素将全部为position:absolute。
因此将使用left移动x轴和y轴。和top
如果你是YUI或Dojo,他们支持自定义事件,例如,参见 YUI自定义事件。您可能会发现这篇文章也很有用。
Okay.
I basicly want an event like
onElementClose
Basicly will trigger a function when another div/block/element comes within a certain area around it (say 5px for eg).
I am sure custom events are possible, I have seen strange examples around.
So unless you are 100% certain this is impossible, please dont say its impossible.
a setInterval that checks if there is an element around it every so long is not acceptable. as there will be hundreds of elements using this event.
If i havent explained this clearly enough please ask
Thanks, Josh.
How will the elements come close, i.e. will they be moved from their original position, or will new elements be created which could potentially come close to an already existing element?
moved from their origonal position, the elements will all be position: absolute.
So will be moved by an x and y axis using "left" and "top"
If you''re YUI or Dojo, they have support for custom events, see, for example, YUI Custom Events. You might find this article useful too.
这篇关于JavaScript中的自定义事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!