
Product
A New Overview in our Dashboard
We redesigned Socket's first logged-in page to display rich and insightful visualizations about your repositories protected against supply chain threats.
ember-img-lazy
Advanced tools
Lazily load images once they enter your viewport.
Uses IntersectionObserver
, does not provide a polyfill and loads
images immediately if IntersectionObserver
is not available.
{{img-lazy src="smile.png" width=200 height=200 alt="Smile"}}
{{img-lazy}}
will add the class img-lazy--loading
once it starts
fetching the image source and applies the class img-lazy--loaded
and src
property when it finishes.
config/environment
:
module.exports = function(environment) {
let ENV = {
// ...
'ember-img-lazy': {
// Don't load images in fastboot, this effectively
// shows the placeholder image until ember takes over.
// Default: false
lazyFastBoot: true,
// The default setting is useful if one wants to show a
// placeholder loading img (i.e. through a background-image).
// Disable to not wait for the images to load to set the src url.
// This is mostly useful with progressive encoded images.
// Default: false
setSrcImmediately: false,
// Config passed to IntersectionObserver.
observerConfig: {
rootMargin: '50px 0px',
threshold: 0.01
}
}
}
// ...
}
@keyframes fade-in {
to {
opacity: 1;
}
}
.img-lazy {
opacity: 0;
}
.img-lazy--loaded {
animation: 200ms fade-in forwards;
background: none;
}
Or with placeholder style, flickers if immediately
is set (default false
).
@keyframes fade-in {
to {
opacity: 1;
}
}
.img-lazy {
opacity: 0;
}
.img-lazy--loading {
opacity: 1;
background: rgba(238, 238, 236, 0.8);
}
.img-lazy--loaded {
animation: 200ms fade-in forwards;
}
ember install ember-img-lazy
ember serve
npm test
(Runs ember try:each
to test your addon against multiple Ember versions)ember test
ember test --server
ember build
For more information on using ember-cli, visit https://ember-cli.com/.
See the Contributing guide for details.
This project is licensed under the MIT License.
FAQs
Lazy load img elements
The npm package ember-img-lazy receives a total of 157 weekly downloads. As such, ember-img-lazy popularity was classified as not popular.
We found that ember-img-lazy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
We redesigned Socket's first logged-in page to display rich and insightful visualizations about your repositories protected against supply chain threats.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.