Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/js/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,16 @@ export default {
* @type {Function}
*/
ready: null,
/**
* Hide images until they are successfully loaded
* @type {boolean}
*/
hideImageBeforeLoaded: false,
/**
* Display images that have not been fully loaded after the time has passed
* @type {number}
*/
timeout: 1000,
show: null,
shown: null,
hide: null,
Expand Down
11 changes: 7 additions & 4 deletions src/js/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,13 @@ export default {
}

// Make the image visible if it fails to load within 1s
this.timeout = setTimeout(() => {
removeClass(image, CLASS_INVISIBLE);
this.timeout = false;
}, 1000);
const { timeout, hideImageBeforeLoaded } = this.options;
if (!hideImageBeforeLoaded) {
this.timeout = setTimeout(() => {
removeClass(image, CLASS_INVISIBLE);
this.timeout = false;
}, timeout);
}
}

return this;
Expand Down