Comments (7)
added in v0.5.0
from laziestloader.
It seems that this works, sort of. It adds the class but it does so before the browser has fully loaded the image. It seems that the class is added when the source is switched, not when it's actually loaded.
from laziestloader.
@zachwise, yes, you're correct. it doesn't actually wait until the image has loaded. My need was tracking whether the element had triggered the scroll-based callback, not whether or not the function of the callback -- which is an image load by default but could be lots of other things -- had actually completed.
I could see how 1) the language/feature is confusing and 2) folks would want what you're talking about, not what I actually implemented.
I'm certainly open to the idea of changing state somehow on an event, like image load. If we add it, I'd want to make sure the solution is still generic, so things like iframes, videos and custom callbacks with no src setting behave predictably.
What were you trying to do? What would you want in an ideal solution?
from laziestloader.
I was hoping to smooth out the loading of images as they come into view by fading them in. Right now I was using the ll-loaded class to change the opacity but it gets applied before the image actually loads. which means the image pops into view instead of fading. Here's an example of what I'm working on: http://picturestory.knightlab.com/stories/jackie.html
from laziestloader.
It looks like I could just use jquery's load method to find out when something loads, so it's up to you if you think it's needed for this library or not.
from laziestloader.
@zachwise fwiw, today I needed the same functionality you do, so I've started the feature-onload
branch to experiment.
from laziestloader.
I've changed this in v0.5.1 so images fire their callback and update class names onload
, and video and audio elements do it onloadstart
. Every other situation continues to do it immediately when the viewport position triggers the callback.
from laziestloader.
Related Issues (16)
- sort widths HOT 1
- Inline element sizing issues HOT 2
- Allow multiple, configurable patterns for substitution HOT 5
- flag for "in view" instead of simply on scroll HOT 5
- fadeIn() images on lazyLoad HOT 4
- Slug-based widths are not sorted correctly HOT 1
- {{size}} variable doesn't work in mustache templates HOT 1
- Laziestloader sans jQuery HOT 8
- iPhone X uses @3x assets
- JQMIGRATE deprecation
- Prevent loading of smaller images on resize
- Expose the bestFit method HOT 1
- throttle scroll event HOT 1
- Sorten data-height-multiplier to simply data-ratio HOT 1
- Occasinally not loading assets on load HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laziestloader.