Skip to content

Commit 6558293

Browse files
committedJul 2, 2020
extends placeholder feature to any background
1 parent 2aca9ca commit 6558293

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed
 

Diff for: ‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ observer.triggerLoad(coolImage);
207207
Sometimes image loading takes a long time. For this case, you can add a placeholder color:
208208

209209
```html
210-
<img class="lozad" data-placeholder-color="red" data-src="image.png" />
210+
<img class="lozad" data-placeholder="red" data-src="image.png" />
211211
```
212212

213213
Lozad set the background of `img` element and users will see the fallback.

Diff for: ‎demo/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ <h1><a href="https://github.com/ApoorvSaxena/lozad.js"><strong>Lozad.js</strong>
5858
<h1>Lozad.js - Performant Lazy Loading Library</h1>
5959
</article>
6060
<article class="thumb">
61-
<img class="lozad" data-placeholder-color="#583624" data-src="images/thumbs/01.jpg" data-index="1" />
61+
<img class="lozad" data-placeholder="#583624" data-src="images/thumbs/01.jpg" data-index="1" />
6262
<noscript><img src="images/thumbs/01.jpg" data-index="1" /></noscript>
6363
<h2>Image 1</h2>
6464
</article>

Diff for: ‎dist/lozad.es.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ function markAsLoaded(element) {
8484
}
8585

8686
function preLoad(element) {
87-
if (element.getAttribute('data-placeholder-color')) {
88-
element.style.backgroundColor = element.getAttribute('data-placeholder-color');
87+
if (element.getAttribute('data-placeholder')) {
88+
element.style.background = element.getAttribute('data-placeholder');
8989
}
9090
}
9191

Diff for: ‎dist/lozad.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@
9090
}
9191

9292
function preLoad(element) {
93-
if (element.getAttribute('data-placeholder-color')) {
94-
element.style.backgroundColor = element.getAttribute('data-placeholder-color');
93+
if (element.getAttribute('data-placeholder')) {
94+
element.style.background = element.getAttribute('data-placeholder');
9595
}
9696
}
9797

Diff for: ‎dist/lozad.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ‎src/lozad.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ function markAsLoaded(element) {
7979
}
8080

8181
function preLoad(element) {
82-
if (element.getAttribute('data-placeholder-color')) {
83-
element.style.backgroundColor = element.getAttribute('data-placeholder-color')
82+
if (element.getAttribute('data-placeholder')) {
83+
element.style.background = element.getAttribute('data-placeholder')
8484
}
8585
}
8686

0 commit comments

Comments
 (0)