Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
extends placeholder feature to any background
  • Loading branch information
igorkamyshev committed Jul 2, 2020
1 parent 2aca9ca commit 6558293
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -207,7 +207,7 @@ observer.triggerLoad(coolImage);
Sometimes image loading takes a long time. For this case, you can add a placeholder color:

```html
<img class="lozad" data-placeholder-color="red" data-src="image.png" />
<img class="lozad" data-placeholder="red" data-src="image.png" />
```

Lozad set the background of `img` element and users will see the fallback.
Expand Down
2 changes: 1 addition & 1 deletion demo/index.html
Expand Up @@ -58,7 +58,7 @@ <h1><a href="https://github.com/ApoorvSaxena/lozad.js"><strong>Lozad.js</strong>
<h1>Lozad.js - Performant Lazy Loading Library</h1>
</article>
<article class="thumb">
<img class="lozad" data-placeholder-color="#583624" data-src="images/thumbs/01.jpg" data-index="1" />
<img class="lozad" data-placeholder="#583624" data-src="images/thumbs/01.jpg" data-index="1" />
<noscript><img src="images/thumbs/01.jpg" data-index="1" /></noscript>
<h2>Image 1</h2>
</article>
Expand Down
4 changes: 2 additions & 2 deletions dist/lozad.es.js
Expand Up @@ -84,8 +84,8 @@ function markAsLoaded(element) {
}

function preLoad(element) {
if (element.getAttribute('data-placeholder-color')) {
element.style.backgroundColor = element.getAttribute('data-placeholder-color');
if (element.getAttribute('data-placeholder')) {
element.style.background = element.getAttribute('data-placeholder');
}
}

Expand Down
4 changes: 2 additions & 2 deletions dist/lozad.js
Expand Up @@ -90,8 +90,8 @@
}

function preLoad(element) {
if (element.getAttribute('data-placeholder-color')) {
element.style.backgroundColor = element.getAttribute('data-placeholder-color');
if (element.getAttribute('data-placeholder')) {
element.style.background = element.getAttribute('data-placeholder');
}
}

Expand Down
2 changes: 1 addition & 1 deletion dist/lozad.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/lozad.js
Expand Up @@ -79,8 +79,8 @@ function markAsLoaded(element) {
}

function preLoad(element) {
if (element.getAttribute('data-placeholder-color')) {
element.style.backgroundColor = element.getAttribute('data-placeholder-color')
if (element.getAttribute('data-placeholder')) {
element.style.background = element.getAttribute('data-placeholder')
}
}

Expand Down

0 comments on commit 6558293

Please sign in to comment.