ressio / lazy-load-xt

Lazy load XT is a jQuery plugin for images, videos and other media
http://ress.io/lazy-load-xt-jquery/
MIT License
1.36k stars 243 forks source link

jquery 1.4.x seems doesn't work in jquery mobile. #3

Closed axacheng closed 10 years ago

axacheng commented 10 years ago

As subject that i had a hard time to debug the strange issue(the next image didn't show up once the scroll down event triggered ) until i found the barely problem came from jquery1.4.2 break the thing. Now, i've to downgrade from jquery 1.4.2 to jquery 1.3.2. and everything works perfectly! (Thanks for your contribution)

btw, Could you please try to use jquery 1.4.2 on below example and let me know how it works ?

view-source:http://ressio.github.io/lazy-load-xt/demo/jqmobile.htm#page2

dryabov commented 10 years ago

Try latest patch: https://raw.github.com/ressio/lazy-load-xt/822364dc36d0f275092787a9049a5129b330e097/src/jquery.lazyloadxt.js

axacheng commented 10 years ago

Thanks man! I just switched to jquery mobile 1.4.2 now it's working great! what was the trick you did to fix it ?

dryabov commented 10 years ago

The main problem with scroll is that scroll event is not bubble, so it's necessary to know exact element that is scrolled. In most cases it is document and window. LazyLoadXT binds to window's scroll event, and in jQueryMobile 1.4 it doesn't work. But binding to document work. So, latest patch fixes the issue by binding to both document's and window's events.

PS. Actually I just run

$(['*',document,window]).each(function() {
    $(this).bind('scroll', function(e){console.log(e);});
});

to see what element triggers scroll event.