-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
575 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,59 @@ | ||
.image-placeholder-lqip { | ||
-ms-filter: progid:DXImageTransform.Microsoft.Blur(PixelRadius='20'); | ||
filter: blur(20px); | ||
} | ||
|
||
.image-placeholder-wrapper { | ||
position: relative; | ||
display: inline-block; | ||
filter: blur(0); | ||
transition: filter 0.2s ease-out; | ||
:not(.image-placeholder-complete) { | ||
filter: blur(20px); | ||
.image-placeholder-opacity { | ||
opacity: 0; | ||
} | ||
} | ||
.image-placeholder-opacity { | ||
transition: opacity 0.2s ease-out; // background: #fff; | ||
display: block; | ||
position: absolute; | ||
width: 100%; | ||
height: 100%; | ||
left: 0; | ||
top: 0; | ||
.image-placeholder-element { | ||
display: block; | ||
width: 100%; | ||
height: 100%; | ||
background: 0 0 / cover no-repeat; | ||
} | ||
} | ||
.blur-mixin (@value: 20) { | ||
& { | ||
-ms-filter: progid:DXImageTransform.Microsoft.Blur(PixelRadius='20'); // filter: url(#blur-lqip); | ||
filter: blur(~"@{value}px"); | ||
} | ||
} | ||
|
||
.image-placeholder-lqip { | ||
.blur-mixin (); | ||
} | ||
|
||
.image-placeholder-no-js { | ||
position: absolute; | ||
opacity: .01; | ||
visibility: hidden; | ||
} | ||
|
||
.image-placeholder-wrapper { | ||
position: relative; | ||
display: inline-block; | ||
>img { | ||
position: static; | ||
} | ||
>.image-placeholder-svg { | ||
position: absolute; | ||
display: block; | ||
left: 0; | ||
top: 0; | ||
width: 100%; | ||
height: 100%; | ||
svg { | ||
max-width: 100%; | ||
max-height: 100%; | ||
} | ||
} | ||
.blur-mixin (0); | ||
transition: filter 0.2s ease-out; | ||
:not(.image-placeholder-complete) { | ||
.blur-mixin (); | ||
.image-placeholder-opacity { | ||
// opacity: 0; | ||
} | ||
} | ||
.image-placeholder-opacity { | ||
transition: opacity 0.2s ease-out; // background: #fff; | ||
display: block; | ||
position: absolute; | ||
width: 100%; | ||
height: 100%; | ||
left: 0; | ||
top: 0; | ||
.image-placeholder-element { | ||
display: block; | ||
width: 100%; | ||
height: 100%; | ||
background: 0 0 / cover no-repeat; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
<license>Released under dual license LGPL v3 | MIT</license> | ||
<authorEmail>[email protected]</authorEmail> | ||
<authorUrl>www.tbela.net</authorUrl> | ||
<version>2.4</version> | ||
<version>2.4.1</version> | ||
<description>PLG_SYSTEM_GZIP_XML_DESCRIPTION</description> | ||
<files> | ||
<folder>css</folder> | ||
|
@@ -29,6 +29,8 @@ | |
<filename>cssloader.min.js</filename> | ||
<filename>imagesloader.js</filename> | ||
<filename>imagesloader.min.js</filename> | ||
<filename>imagesnojs.js</filename> | ||
<filename>imagesnojs.min.js</filename> | ||
<filename>worker_version</filename> | ||
<filename plugin="gzip">gzip.php</filename> | ||
</files> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
// @ts-check | ||
|
||
/** | ||
* lazy image laoder | ||
* @package GZip Plugin | ||
* @copyright Copyright (C) 2005 - 2018 Thierry Bela. | ||
* | ||
* dual licensed | ||
* | ||
* @license LGPL v3 | ||
* @license MIT License | ||
*/ | ||
|
||
LIB.ready(function(undef) { | ||
// intersection-observer.min.js | ||
|
||
if (!("srcset" in new Image())) { | ||
// try { | ||
|
||
document.body.insertAdjacentHTML( | ||
"beforeend", | ||
"<svg xmlns=http://www.w3.org/2000/svg width=1 height=1>" + | ||
"<defs>" + | ||
"<filter id=blur-lqip width=100% height=100% >" + | ||
"<feGaussianBlur stdDeviation=20 />" + | ||
'</filter>' + | ||
'</defs>'+ | ||
'</svg>' | ||
); | ||
} | ||
|
||
function lazyload() { | ||
LIB.images.lazy(".image-placeholder").on({ | ||
|
||
/** | ||
* | ||
* @param {HTMLImageElement} img | ||
* @param {HTMLImageElement} oldImage | ||
*/ | ||
preload: function(img, oldImage) { | ||
|
||
const legacy = !("currentSrc" in img); | ||
|
||
if (!legacy) { | ||
oldImage.insertAdjacentHTML( | ||
"beforebegin", | ||
'<span class=image-placeholder-wrapper><span class=image-placeholder-opacity><span class=image-placeholder-element style="background-image:url(\'' + | ||
(img.currentSrc || img.src) + | ||
"')\">" | ||
); | ||
} | ||
|
||
else { | ||
oldImage.insertAdjacentHTML( | ||
"beforebegin", | ||
"<span class=image-placeholder-wrapper><span class=image-placeholder-svg><svg width=100% height=100% version=1.1 xmlns=http://www.w3.org/2000/svg >" + | ||
'<image xlink:href="' + | ||
(img.currentSrc || img.src) + | ||
'" width=100% height=100% filter=url(#blur-lqip) x=0 y=0 />"' | ||
); | ||
} | ||
|
||
const container = oldImage.previousElementSibling; | ||
|
||
if (legacy) { | ||
|
||
if ( typeof window.CustomEvent != "function" ) { | ||
|
||
function CustomEvent ( event, params ) { | ||
params = params || { bubbles: false, cancelable: false, detail: undefined }; | ||
const evt = document.createEvent( 'CustomEvent' ); | ||
evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail ); | ||
return evt; | ||
} | ||
|
||
CustomEvent.prototype = window.Event.prototype; | ||
} | ||
|
||
const svg = container.querySelector('svg'); | ||
// const svgImage = container.querySelector('svg image'); | ||
function resize () { | ||
|
||
const height = this.height; | ||
const width = this.width; | ||
|
||
svg.setAttribute('height', height); | ||
svg.setAttribute('width', width); | ||
|
||
// svgImage.setAttribute('height', height); | ||
// svgImage.setAttribute('width', width); | ||
} | ||
|
||
img.addEventListener('sourcechange', resize); | ||
img.addEventListener('load', resize); | ||
} | ||
|
||
oldImage.classList.remove( | ||
"image-placeholder-lqip", | ||
"image-placeholder-svg", | ||
"image-placeholder" | ||
); | ||
container.insertBefore(oldImage, container.firstElementChild); | ||
}, | ||
load: function(img, oldImage) { | ||
if (oldImage.dataset.src != undef) { | ||
oldImage.src = oldImage.dataset.src; | ||
// oldImage.removeAttribute("data-src"); | ||
} | ||
|
||
if (oldImage.dataset.srcset != undef) { | ||
oldImage.srcset = oldImage.dataset.srcset; | ||
// oldImage.removeAttribute("data-srcset"); | ||
} | ||
|
||
setTimeout(function() { | ||
let container = oldImage; | ||
|
||
oldImage.removeAttribute("data-srcset"); | ||
oldImage.removeAttribute("data-src"); | ||
|
||
while ( | ||
container != undef && | ||
!container.classList.contains( | ||
"image-placeholder-wrapper" | ||
) | ||
) { | ||
container = container.parentElement; | ||
} | ||
|
||
container.classList.add("image-placeholder-complete"); | ||
|
||
setTimeout(function() { | ||
|
||
// if (container.parentElement != null) { | ||
|
||
container.parentElement.insertBefore( | ||
oldImage, | ||
container | ||
); | ||
|
||
container.parentElement.removeChild(container); | ||
// } | ||
|
||
}, 10); | ||
}, 10); | ||
} | ||
}); | ||
} | ||
|
||
if ( | ||
!( | ||
"IntersectionObserver" in window && | ||
"IntersectionObserverEntry" in window && | ||
"intersectionRatio" in window.IntersectionObserverEntry.prototype | ||
) | ||
) { | ||
const script = document.createElement("script"); | ||
/*script.onreadystatechange =*/ script.onload = lazyload; | ||
script.defer = true; | ||
script.async = true; | ||
script.src = "{script-src}"; | ||
document.body.appendChild(script); | ||
} else { | ||
if (!("isIntersecting" in window.IntersectionObserverEntry.prototype)) { | ||
Object.defineProperty( | ||
window.IntersectionObserverEntry.prototype, | ||
"isIntersecting", | ||
{ | ||
get: function() { | ||
return this.intersectionRatio > 0; | ||
} | ||
} | ||
); | ||
} | ||
|
||
lazyload(); | ||
} | ||
}); |
Oops, something went wrong.