New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scrolling on chrome - image does not load until the viewport stops scrolling #139
Comments
To be honest I can not reproduce your experience. Is this also happening on your desktop browser or only for mobile? In case this happens only on mobile check out the following page (with your mobile browser): http://andyshora.com/mobile-scroll-event-problems.html (is scrollTop updated instantly while scrolling) lazySizes only throttles the scroll event, it isn't debounced. Additionally lazySizes should start a download before an image is coming into view. Maybe you can change by using the options. You could try: window.lazySizesConfig = window.lazySizesConfig || {};
lazySizesConfig.throttle = 70; //default: 125
lazySizesConfig.expand = 500; //default: 360
lazySizesConfig.expFactor = 1.5; //default: 2
lazySizesConfig.loadMode = 3; //default 2 |
oh crap yes its only on mobile. thanks for linking that article... in that case is there a workaround to make lazySizes load the images on mobile while scrolling? |
You can try: document.addEventListener('touchmove', lazySizes.loader.checkElems, true); My question most modern smartphones should trigger scroll events while scrolling. What smartphone and android version are you using? |
i'm using iphone 6. and i'm using Google Chrome for iPhone. Not seeing the images load on http://afarkas.github.io/lazysizes/#examples until scrolling comes to a stop. |
http://developer.telerik.com/featured/scroll-event-change-ios-8-big-deal/ As already said you can try: document.addEventListener('touchmove', lazySizes.loader.checkElems, true); |
Or better: document.addEventListener('touchmove', lazySizes.loader.checkElems, true);
document.addEventListener('touchend', function(){
setTimeout(lazySizes.loader.checkElems, 300);
}, true); |
Hmmm have u added those event handlers in the demo site ?
|
no |
aight let u know once i've tried your suggestions ! |
I've tried it out, putting those document event listeners did not help. Images still doesn't load until the scrolling stops. I'm not sure if you misunderstood what I meant, but basically what I want was for the images to load while while you scroll. The current behavior on the phone is to only load after the scrolling stops. iOS iphone v8.3, chrome v44.0.2403.67. |
More details: So i put a little box on the bottom left to track the
|
I'm going on vacation for two weeks, so I can't help you until then. |
Sorry for not helping. This is a constrain of the iOS webview, which is used by Chrome on iOS (It isn't actually a blink engine). While scrolling the webview doesn't paint any DOM changes. |
I see. Ok thanks Sent from my iPhone
|
The same happens on MacOS in chrome (desktop) if you scroll with touch pad (or with mouse touch). Scroll events fire, requests for images show as pending, but the images are loaded after scrolling stops (and the load time shows as <5ms). Works ok if you scroll by dragging scrollbar Works ok in safari. |
I just hit this issue too. fwiw here's the solution I used and it seems to work pretty well.
|
@epoberezkin indeed it happens on Chrome on MacOS desktop. I found that if you give the img explicit dimensions, either in px or %, the issue goes away. |
have this issue on desctop Chrome and Opera(windows), solutions by aaronorosen and richardcalahan don't help. Images don't load until I stop scrolling, but only when I do it with mouse wheel. When I drag scrollbar it's ok |
I ran into this problem just using plain old IntersectionObserver (never used lazysizes) but this GitHub issue is the only place I can find talking about it. It looks like Chrome updates the DOM (and downloads the image in the background) but sometimes doesn't actually draw the image until scrolling has stopped. For me it:
Basically I think it's a performance optimisation in Chrome and will only show up on slower devices. Giving the image explicit dimensions will reduce the chance of a DOM reflow so might reduce the issue but not eliminate it. |
I've checked out the demo and tested it on my mobile chrome http://afarkas.github.io/lazysizes/#examples
It appears the behavior for lazy loading is to start loading the image only after the view port have stop scrolling. It's quite an awkward experience because users will have to stop scrolling and wait for the images to load, rather than scroll and have the images start loading in parallel while the page is still scrolling.
The text was updated successfully, but these errors were encountered: