Skip to content

Commit

Permalink
feat(imgixtag): optional class nolazyload to selectively disable lazy…
Browse files Browse the repository at this point in the history
… loading

Added support for a new optional class 'nolazyload' that when use will selectively disable lazy loading for that element while using lazysizes.
  • Loading branch information
atlawrie authored and sherwinski committed Jul 7, 2022
1 parent 0a882b8 commit 98efb8c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/ImgixTag.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ var ImgixTag = (function () {
this.baseUrl = this._buildBaseUrl();
this.baseUrlWithoutQuery = this.baseUrl.split('?')[0];

//manual override to use sizes, srcset, and src when lazyloading
if(util.isString(this.el.className)){
if (this.el.className.includes("nolazyload")){
this.settings.sizesAttribute = "sizes";
this.settings.srcsetAttribute = "srcset";
this.settings.srcAttribute = "src";
}
}

if (util.isString(this.settings.sizesAttribute)) {
this.el.setAttribute(this.settings.sizesAttribute, this.sizes());
}
Expand Down

0 comments on commit 98efb8c

Please sign in to comment.