MRchildNEO / svgweb

Automatically exported from code.google.com/p/svgweb
Other
0 stars 0 forks source link

Jquery $(window).scroll event will not fire after including the latest SVG Web release into the project #524

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Include the dracolisk SVG Web source file into your project
2. Include jquery/1.4.2 into your project
3. Add a event handler for the $(window).scroll
4. Scroll your browser window using Internet Explorer 8 

What is the expected output? What do you see instead?
The expected output would be for my $(window).scroll event to fire ... it does 
not .

What version of the product are you using? On what operating system,
browser, and version of Flash?
This is a problem with IE 8 , Firefox, Opera and Chrome had no issues.

Please provide any additional information below. Reduced test cases are
always appreciated!
Replacing the SVG Web source files with the source files from Gelatinous Cube 
release will fix the issue.

Original issue reported on code.google.com by FlorinaM...@gmail.com on 22 Jun 2010 at 10:16

GoogleCodeExporter commented 8 years ago

Original comment by bradneub...@gmail.com on 22 Jun 2010 at 11:13

GoogleCodeExporter commented 8 years ago
A simple test case reproducing the issue.

Original comment by cdeon...@gmail.com on 24 Jun 2010 at 7:17

Attachments:

GoogleCodeExporter commented 8 years ago
The diff between Dracolisk and Gelatinous Cube that appears to be causing the 
problem:

} else {
    window.addEventListener = function (type, f, useCapture) {
        if (type.toLowerCase() == "svgload") {
            svgweb.addOnLoad(f);
        }
    };

Original comment by cdeon...@gmail.com on 24 Jun 2010 at 7:36

GoogleCodeExporter commented 8 years ago
How is this causing the issue? Note that the latest SVG Web release requires 
you to subscribe to the SVGLoad event rather than intercepting window.onload.

Original comment by bradneub...@gmail.com on 25 Jun 2010 at 6:32

GoogleCodeExporter commented 8 years ago
I should have mentioned that removing the above code allows the alert to 
display on IE.  I'm examining it further.

Original comment by cdeon...@gmail.com on 26 Jun 2010 at 2:06

GoogleCodeExporter commented 8 years ago
The problem is that we are patching a barely functional window.addEventListener 
into IE and jquery is fooled into using it for the scroll event, which is 
silently ignored.

jquery has this code in jQuery.event.add:

                    if ( elem.addEventListener ) {
                        elem.addEventListener( type, eventHandle, false );

                    } else if ( elem.attachEvent ) {
                        elem.attachEvent( "on" + type, eventHandle );
                    }

The question is whether we try to do a better job at implementing 
window.addEventListener for IE which is not too hard to do (by just passing on 
to attachEvent), or do we decide that this may do more harm that good, say if 
another library or page developer infers too much from the existence of 
window.addEventListener and does something that does not work?

Original comment by grick23@gmail.com on 26 Jun 2010 at 2:14

GoogleCodeExporter commented 8 years ago
The following code is from jquery. While this is for document instead of 
window, the example demonstrates the point I was making in the previous 
comment. This code assumes that if addEventListener is implemented, then 
removeEventListener is also implemented. In this code, if removeEventListener 
is not implemented, an exception would probably be thrown here and the library 
would never initialize. So, we should consider that someone could do the same 
kind of thing for the load event on the window.

// Cleanup functions for the document ready method
if ( document.addEventListener ) {
    DOMContentLoaded = function() {
        document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
        jQuery.ready();
    };

Original comment by grick23@gmail.com on 26 Jun 2010 at 2:31

GoogleCodeExporter commented 8 years ago
Good point Rick. Since SVG Web is an emulation library I want to keep things 
patched in as much as possible; we should probably go the distance and just 
implement addEventListener to pass through to attachEvent for exactly the 
reason you just pointed out.

Original comment by bradneub...@gmail.com on 27 Jun 2010 at 12:34

GoogleCodeExporter commented 8 years ago
I've created this patch which simply modifies the window.addEventListener to 
pass through to attachEvent in the case that it's IE.  I'm not an expert in 
Javascript or the present codeline, so would someone be able to review it for 
correctness?  I have verified that the fix allows the alert to display for the 
test case I created.

Original comment by cdeon...@gmail.com on 28 Jun 2010 at 12:47

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by bradneub...@gmail.com on 28 Jun 2010 at 4:12

GoogleCodeExporter commented 8 years ago
Fixed in r1200.

Original comment by grick23@gmail.com on 2 Jul 2010 at 2:54