All Projects β†’ bennypowers β†’ lazy-image

bennypowers / lazy-image

Licence: GPL-3.0 license
Lazily load your images with <lazy-image> custom element

Programming Languages

HTML
75241 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to lazy-image

svelte-webcomponent-boilerplate
πŸ— Create your HTML5 Web Component with Svelte. Made your web components with this user-friendly boilerplate
Stars: ✭ 58 (+38.1%)
Mutual labels:  webcomponents, custom-elements
toggle-icon
toggle-icon is a custom element created with Polymer. It provides an extremely powerful and customizable switch that looks like a paper-icon-button.
Stars: ✭ 21 (-50%)
Mutual labels:  webcomponents, custom-elements
smart-webcomponents-community
Material & Bootstrap Web Components built with Smart
Stars: ✭ 30 (-28.57%)
Mutual labels:  webcomponents, custom-elements
pattern-library
AXA CH UI component library. Please share, comment, create issues and work with us!
Stars: ✭ 103 (+145.24%)
Mutual labels:  webcomponents, custom-elements
modulor-html
Missing template engine for Web Components
Stars: ✭ 36 (-14.29%)
Mutual labels:  webcomponents, custom-elements
MoleculeJS
A library for creating fast and reactive Custom Elements
Stars: ✭ 39 (-7.14%)
Mutual labels:  webcomponents, custom-elements
paper-chip
A chip web component made with Polymer 2 following Material Design guidelines
Stars: ✭ 30 (-28.57%)
Mutual labels:  webcomponents, custom-elements
Markuplint
A Linter for All Markup Languages.
Stars: ✭ 193 (+359.52%)
Mutual labels:  webcomponents, custom-elements
crab
JavaScript library for building user interfaces with Custom Elements, Shadow DOM and React like API
Stars: ✭ 22 (-47.62%)
Mutual labels:  webcomponents, custom-elements
symbiote.js
Simple, light and very powerful library to create embedded components for any purpose, with a data flow management included.
Stars: ✭ 40 (-4.76%)
Mutual labels:  webcomponents, custom-elements
web-components
A set of high-quality standards based web components for enterprise web applications. Part of Vaadin 20+
Stars: ✭ 322 (+666.67%)
Mutual labels:  webcomponents, custom-elements
lit-components
Moved to https://github.com/vaadin/component-mixins
Stars: ✭ 59 (+40.48%)
Mutual labels:  webcomponents, custom-elements
Standalone
Create framework agnostic components that are truly reusable and interoperable with all the benefits of the React ecosystem – using the HTML5 custom elements API to extend HTML's vocabulary.
Stars: ✭ 205 (+388.1%)
Mutual labels:  webcomponents, custom-elements
api-viewer-element
API documentation and live playground for Web Components. Based on Custom Elements Manifest format
Stars: ✭ 222 (+428.57%)
Mutual labels:  webcomponents, custom-elements
Hybrids
Extraordinary JavaScript framework with unique declarative and functional architecture
Stars: ✭ 2,529 (+5921.43%)
Mutual labels:  webcomponents, custom-elements
material-webcomponents
Material Design implemented in Web Components (Custom Elements v1)
Stars: ✭ 110 (+161.9%)
Mutual labels:  webcomponents, custom-elements
Api Viewer Element
API documentation and live playground for Web Components
Stars: ✭ 121 (+188.1%)
Mutual labels:  webcomponents, custom-elements
Omi
Front End Cross-Frameworks Framework - ε‰η«―θ·¨ζ‘†ζžΆθ·¨εΉ³ε°ζ‘†ζžΆ
Stars: ✭ 12,153 (+28835.71%)
Mutual labels:  webcomponents, custom-elements
notification-service-js
🚦Notification Service based on Custom Elements
Stars: ✭ 16 (-61.9%)
Mutual labels:  webcomponents, custom-elements
lego
πŸš€ Web-components made lightweight & Future-Proof.
Stars: ✭ 69 (+64.29%)
Mutual labels:  webcomponents, custom-elements

Published on webcomponents.org npm (scoped) Build Status Contact me on Codementor

<lazy-image>

Lazily load your images!

πŸš› Get it!

npm i -S @power-elements/lazy-image

πŸ“¦ Load it!

<!-- From CDN -->
<script async type="module" src="https://unpkg.com/@power-elements/lazy-image/lazy-image.js"></script>

<!-- From local installation -->
<script async type="module" src="/node_modules/@power-elements/lazy-image/lazy-image.js"></script>

<!-- In a Module -->
<script type="module">
  import '/node_modules/@power-elements/lazy-image/lazy-image.js';
  // ...
</script>

πŸ’ͺ Use it!

<lazy-image src="image.jpg" alt="Lazy Image">
  <svg slot="placeholder"><use xlink:href="#placeholder-svg"></use></svg>
</lazy-image>

The optional placeholder could be any element. Inline SVG, Pure CSS graphics, or an <img src="data:foo"/> would work best.

πŸ’„ Style it!

You should give your <lazy-image> elements some specific dimensions, since it absolutely positions its shadow children. In most cases, you should set the wrapping element as well as the --lazy-image- custom properties to the known display dimensions of your image.

<style>
html {
  --lazy-image-width: 640px;
  --lazy-image-height: 480px;
}

lazy-image {
  width: var(--lazy-image-width);
  height: var(--lazy-image-height);
}
</style>

<lazy-image src="https://fillmurray.com/640/480"></lazy-image>

<lazy-image> exposes a set of custom properties for your customizing delight:

Property Purpose Default
--lazy-image-width Width of the internal image and placeholder elements 100%
--lazy-image-height Height of the internal image and placeholder elements 100%
--lazy-image-fit object-fit property of the internal image and placeholder elements contain
--lazy-image-fade-duration Duration of the fade in from the placeholder to the image. Set to 0 to disable fading. 0.3s
--lazy-image-fade-easing ease property of the opacity transition for the image and placeholder ease

Browser support

lazy-image manages the loading of your images via an Intersection Observer. In browsers where an Intersection Observer is not present, your images will be loaded immediately much like standard <img/> elements. Conditionally delivering the IntersectionObserver polyfill along with your lazy-images to your users will ensure that all users experience the benefits of loading images lazily. Stay lazy, friend!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].