at this point consider an in-scope memory solution:
var doc = document.documentElement;
doc.onmousemove = (function(prev){
return function(e){
var current = [e.pageX, e.pageY].join(",");
if(current !== prev){
// your stuff here
};
prev = current;
};
})("");
If Safari just fires onmousemove twice with the same value after the second
check for (current !== prev) you can redefine the function itself to speedup
its execution for non problematic browsers.
function myMoveEvent(e){};
var doc = document.documentElement;
doc.onmousemove = (function(i,prev){
// temporary event
return function(e){
// get current position
var current = [e.pageX, e.pageY].join(",");
// compare with last position
if(current !== prev){
// different position, always true first call
myMoveEvent(e);
// if else case has never been reached (0 first call)
if(1 === i)
// redefine the event
doc.onmousemove = myMoveEvent;
// increase the case
++i;
} else
--i; // keep i to zero for bugged browsers
// first two cases or for bugged browsers
// trace last position
prev = current;
};
})(0,"");
Being a user interaction related event plus a temporary (hopefully) bug,
with above code you will slightly slow down the event execution just time to
move the mouse in 2 different positions. After that the execution it will be
simple for every browser, not that stressful for Safari 4 which has a fast
JS engine so it will not decrease its performances at all.
Souds good?
On Thu, Aug 6, 2009 at 12:56 PM, [email protected] <
[email protected]> wrote:
>
> > try before you blame my suggestion. You are not introducing anything
> visible to human eyes
>
> > My proposal will avoid that computation, faster interaction, otherwise
> > double computation and more often than each 15 milliseconds.
>
> No, no - I do recognise the benefits of this approach for simple
> interactions, but right now I need to fix what mousemove should do,
> ie. fire every time the mouse moves (only not twice!). I'm doing mouse
> tracking stuff that needs it.
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---