[jquery-dev] Re: mousemove events double firing in Safari 4
Did you try to use the native JavaScript implementation to observe the event? If not, please try it and post the results here; Maybe the doubled event firing is a browser bug. Using the code: var doc = document.documentElement; doc.onmousemove = function(e){ console.log(e.pageX+', '+e.pageY); } Safari 4 still appears to double fire on each mousemove. I think this is a browser bug! It's the sort of browser bug that jQuery specialises in fixing. The fix I've got so far involves comparing [e.pageX, e.pageY] against a stored [e.pageX, e.pageY] from the last mousemove before deciding to do something. Creates a bit of an annoying overhead on mousemove, though, particularily annoying for browsers that don't have the bug. Anyone any ideas about how to feature detect it? Stephen. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups jQuery Development group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~--~~~~--~~--~--~---
[jquery-dev] Re: mousemove events double firing in Safari 4
Delay the execution as soon as possible. var doc = document.documentElement; doc.onmousemove = (function(i){ return function(e){ if(i !== 0) clearTimeout(i); i = setTimeout(function(){ console.log(e.pageX+', '+e.pageY); i = 0; }, 1); }; })(0); if it is a browser bug, it is probably a double fired event, once for the X and once for the Y axis. On Thu, Aug 6, 2009 at 10:50 AM, stephb...@googlemail.com stephb...@googlemail.com wrote: Anyone any ideas about how to feature detect it? Stephen. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups jQuery Development group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~--~~~~--~~--~--~---
[jquery-dev] Re: mousemove events double firing in Safari 4
I've tested Safari 4.0.2 and FF 3.0.8 using both html5 and xhtml1.0 Strict doctypes. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups jQuery Development group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~--~~~~--~~--~--~---
[jquery-dev] Re: mousemove events double firing in Safari 4
the timer won't fire until 0.029s - that's a 29ms lag! Or worse, if successive mousemoves occur within 15ms of each other, the only one to trigger console.log will be the last one... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups jQuery Development group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~--~~~~--~~--~--~---
[jquery-dev] Re: mousemove events double firing in Safari 4
Exactly so you'll always have the last valid position ... try before you blame my suggestion. You are not introducing anything visible to human eyes ;-) On Thu, Aug 6, 2009 at 11:25 AM, stephb...@googlemail.com stephb...@googlemail.com wrote: the timer won't fire until 0.029s - that's a 29ms lag! Or worse, if successive mousemoves occur within 15ms of each other, the only one to trigger console.log will be the last one... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups jQuery Development group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~--~~~~--~~--~--~---
[jquery-dev] Re: mousemove events double firing in Safari 4
Moreover, application will automatically speedup ( mousemove is greedy for old browsers and if it activates items, classes, etc etc ). Example: you move the mouse quickly over an element which change status, css, colors, etc, but you did not mean it cause you passed away. My proposal will avoid that computation, faster interaction, otherwise double computation and more often than each 15 milliseconds. The only problem I could spot is the stopPropagation over other elements but I guess if you are using one mousemove manager and for the document, you won't need the stopPropagation. Just try On Thu, Aug 6, 2009 at 11:57 AM, Andrea Giammarchi andrea.giammar...@gmail.com wrote: Exactly so you'll always have the last valid position ... try before you blame my suggestion. You are not introducing anything visible to human eyes ;-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups jQuery Development group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~--~~~~--~~--~--~---
[jquery-dev] jquery events binding
Hi all, I propose to add the following new feature in events binding : var o = { start : new Function(), stop : new Function() } // Will be the same as // $(target).bind( 'example.start', o.start ); // $(target).bind( 'example.stop', o.stop ); $(target).bind( 'example', o ); $(target).triggerHandler( 'example.start' ); // Will call start function It is very easy to implement, and would simplify interface. After that, I would be great to normalize all components with the following : $(target).myComponent( { events : { start : new Function(), stop : new Function() }, myOtherParam : 'value' } As jquery supports namespaced events, it should support it fully. Best regards, --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups jQuery Development group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~--~~~~--~~--~--~---
[jquery-dev] JavaScript compiler warnings
In NetBeans IDE 7 there is a good JavaScript integration. For jQuery there comes a long list of warnings. Especially one kind bothers me: function does not always return a value. Is this an oversight due to missing tools, or is this deliberate? Though the nightly build is also concerned, I'll give some line numbers of jquery-1.3.2.js: 375, 1754, 1767, 1957, 2048, 2150, 2250, 2663, 2818, 2931, 3009. I am quite willing to provide a corrected nightly build or whatever. For us this issue could mean dropping jQuery altogether, and I am very fond of jQuery. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups jQuery Development group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~--~~~~--~~--~--~---
[jquery-dev] Re: JavaScript compiler warnings
it's JavaScript nature where undefined is considered a non-result so you can consider it as a false, a null case, or a call that did not produce anything: undefined. This concept is mainly present in the each method. If the callback deliberately returns false, the loop stops. jQuery does not want to force anybody to return something from a function that coul dbe used for whatever case returning different values. Scripting guys ;-) On Thu, Aug 6, 2009 at 9:44 AM, joop_eggen joop.eg...@googlemail.comwrote: In NetBeans IDE 7 there is a good JavaScript integration. For jQuery there comes a long list of warnings. Especially one kind bothers me: function does not always return a value. Is this an oversight due to missing tools, or is this deliberate? Though the nightly build is also concerned, I'll give some line numbers of jquery-1.3.2.js: 375, 1754, 1767, 1957, 2048, 2150, 2250, 2663, 2818, 2931, 3009. I am quite willing to provide a corrected nightly build or whatever. For us this issue could mean dropping jQuery altogether, and I am very fond of jQuery. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups jQuery Development group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~--~~~~--~~--~--~---
[jquery-dev] Re: mousemove events double firing in Safari 4
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 jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~--~~~~--~~--~--~---
[jquery-dev] Re: mousemove events double firing in Safari 4
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, stephb...@googlemail.com stephb...@googlemail.com 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 jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~--~~~~--~~--~--~---
[jquery-dev] Re: mousemove events double firing in Safari 4
// if else case has never been reached (0 first call) if(1 === i) // redefine the event doc.onmousemove = myMoveEvent; Haha!! Now we're talking! On-call feature detection. Perfect, thank you very much! I submitted a bug report to Apple. I'll check the problem on the next couple of Safari updates, and if it doesn't get fixed I'll bring it up again. Cheers, Stephen. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups jQuery Development group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~--~~~~--~~--~--~---
[jquery-dev] Re: jquery events binding
I thought events were event.namespace you're suggesting the ability to bind multiple namespaces to one event? Don't you mean multiple events to one namespace? And what's so bad about just using the normal object notation instead? $(target).bind({ 'example.start': new Function(), 'example.stop': new Function() }); ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name] ludovic wrote: Hi all, I propose to add the following new feature in events binding : var o = { start : new Function(), stop : new Function() } // Will be the same as // $(target).bind( 'example.start', o.start ); // $(target).bind( 'example.stop', o.stop ); $(target).bind( 'example', o ); $(target).triggerHandler( 'example.start' ); // Will call start function It is very easy to implement, and would simplify interface. After that, I would be great to normalize all components with the following : $(target).myComponent( { events : { start : new Function(), stop : new Function() }, myOtherParam : 'value' } As jquery supports namespaced events, it should support it fully. Best regards, --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups jQuery Development group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~--~~~~--~~--~--~---
[jquery-dev] $('divfoo/div') and application/xml
$('divfoo/div') doesn't work when the content type is 'application/ xml'. I guess this is because an XML DOM doesn't support innerHTML()? One might use the content type 'application/xml', for example to include inline SVG Here's an example of $('divfoo/div') not working, http://www.sfu.ca/~jdbates/tmp/jquery/200908060/a/index.xml Here's a naive patch to make $('divfoo/div') work even when the content type is 'application/xml', http://www.sfu.ca/~jdbates/tmp/jquery/200908060/patch And here's the same example, but using a patched jquery-nightly.js and working, http://www.sfu.ca/~jdbates/tmp/jquery/200908060/b/index.xml Is a patch like this welcome? May I open a ticket? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups jQuery Development group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~--~~~~--~~--~--~---
[jquery-dev] Re: Changes to closest (#6507) breaks $(event.target).closest(...) in event handlers
Could someone please update the nightly? http://code.jquery.com/jquery-nightly.js It still contains this closest issue (rev. 6507). On Jul 28, 10:05 am, John Resig jere...@gmail.com wrote: Is there any specific reason that context is set to the element for $(elem)? Could it not be document unless an alternative is given: $(elem, context) Index: src/core.js === --- src/core.js (revision 6520) +++ src/core.js (working copy) @@ -53,7 +53,8 @@ // Handle $(DOMElement) if ( selector.nodeType ) { - this.context = this[0] = selector; + this[0] = selector; + this.context = context || document; this.length++; return this; } I don't think that would work since $(foo, DOMElement) wouldn't have a context set. It would require a little more tweaking in order to get to a solid state. It's ok though, it's already been backed out. --John --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups jQuery Development group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~--~~~~--~~--~--~---
[jquery-dev] Re: $('divfoo/div') and application/xml
Yeah, file a bug and attach the patch and I can look in to it. --John On Thu, Aug 6, 2009 at 2:08 PM, Jack Bates jack.ba...@gmail.com wrote: $('divfoo/div') doesn't work when the content type is 'application/ xml'. I guess this is because an XML DOM doesn't support innerHTML()? One might use the content type 'application/xml', for example to include inline SVG Here's an example of $('divfoo/div') not working, http://www.sfu.ca/~jdbates/tmp/jquery/200908060/a/index.xmlhttp://www.sfu.ca/%7Ejdbates/tmp/jquery/200908060/a/index.xml Here's a naive patch to make $('divfoo/div') work even when the content type is 'application/xml', http://www.sfu.ca/~jdbates/tmp/jquery/200908060/patchhttp://www.sfu.ca/%7Ejdbates/tmp/jquery/200908060/patch And here's the same example, but using a patched jquery-nightly.js and working, http://www.sfu.ca/~jdbates/tmp/jquery/200908060/b/index.xmlhttp://www.sfu.ca/%7Ejdbates/tmp/jquery/200908060/b/index.xml Is a patch like this welcome? May I open a ticket? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups jQuery Development group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~--~~~~--~~--~--~---
[jquery-dev] Re: jquery events binding
And what's so bad about just using the normal object notation instead? $(target).bind({ 'example.start': new Function(), 'example.stop': new Function() }); Is that possible? I can't find it mentioned in the documentation, and after a *brief* look at the 1.3.2 source I can't see it there. Sounds like a neat idea though - at least for a plugin. -- Már --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups jQuery Development group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~--~~~~--~~--~--~---
[jquery-dev] Re: jquery events binding
It is very simple to accomplish as a plugin: jQuery.fn.multibind = function( events ) { var $this = this; jQuery.each( events, function( name, fn ) { $this.bind( name, fn ); } ); }; -- Brandon Aaron On Thu, Aug 6, 2009 at 2:42 PM, Mármar.orlygs...@gmail.com wrote: And what's so bad about just using the normal object notation instead? $(target).bind({ 'example.start': new Function(), 'example.stop': new Function() }); Is that possible? I can't find it mentioned in the documentation, and after a *brief* look at the 1.3.2 source I can't see it there. Sounds like a neat idea though - at least for a plugin. -- Már --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups jQuery Development group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~--~~~~--~~--~--~---
[jquery-dev] Re: $('divfoo/div') and application/xml
Jack, if it is XML it cannot be dirty and there are no problems to fix with the string. I bet your wrap[1] and wrap[2] will always be and , the last array, and I think it is good, being XML, if the browser raise an error if passed string is not valid XML. Accordingly, you do not need anything there except what you already wrote: div = new DOMParser().parseFromString('div' + elem + '/div', context.contentType).documentElement; But this modification produces an XML with two divs, rather than one, so it is not that simple, it should be just elem, and it should be elsewhere: var isXML = jQuery.isXML(context), ret = [], scripts = [], div = isXML ? (new DOMParser().parseFromString(elem, context.contentType).documentElement) : context.createElement(div); if(isXML) { do some stuff to retrieve nodes } else { code as is } I did not test but what I am sure about those wrap cases should never exists with XML. Hope this helps. Regards --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups jQuery Development group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~--~~~~--~~--~--~---
[jquery-dev] Adding in support for 'focus' and 'blur' events using .live and .die
Hey guys, I know about .livequery, but it didn't work for me. As a result, I wrote a plugin called bond (uses .bond and .unbond) that implements event delegation for 'focus' and 'blur' and works with *any* valid selector. The only downside is that I have to use a plugin to achieve this functionality. Shouldn't something like this go into the core? Code: http://groups.google.com/group/jquery-dev/browse_thread/thread/3b3731308f23cbb6 Cheers, Trey --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups jQuery Development group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~--~~~~--~~--~--~---
[jquery-dev] Re: $('divfoo/div') and application/xml
Thanks, I filed a bug and attached the patch, http://dev.jquery.com/ticket/5022 On Aug 6, 11:43 am, John Resig jere...@gmail.com wrote: Yeah, file a bug and attach the patch and I can look in to it. --John On Thu, Aug 6, 2009 at 2:08 PM, Jack Bates jack.ba...@gmail.com wrote: $('divfoo/div') doesn't work when the content type is 'application/ xml'. I guess this is because an XML DOM doesn't support innerHTML()? One might use the content type 'application/xml', for example to include inline SVG Here's an example of $('divfoo/div') not working, http://www.sfu.ca/~jdbates/tmp/jquery/200908060/a/index.xmlhttp://www.sfu.ca/%7Ejdbates/tmp/jquery/200908060/a/index.xml Here's a naive patch to make $('divfoo/div') work even when the content type is 'application/xml', http://www.sfu.ca/~jdbates/tmp/jquery/200908060/patchhttp://www.sfu.ca/%7Ejdbates/tmp/jquery/200908060/patch And here's the same example, but using a patched jquery-nightly.js and working,http://www.sfu.ca/~jdbates/tmp/jquery/200908060/b/index.xmlhttp://www.sfu.ca/%7Ejdbates/tmp/jquery/200908060/b/index.xml Is a patch like this welcome? May I open a ticket? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups jQuery Development group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~--~~~~--~~--~--~---