perf: optimize lazyload image

This commit is contained in:
XPoet 2021-01-08 11:55:45 +08:00
parent 2c454fa8a8
commit 31444f2458
4 changed files with 63 additions and 24 deletions

View File

@ -87,11 +87,10 @@ a {
// ====================================================================== // ======================================================================
img { img {
&[lazyload] { &[lazyload] {
padding: 20px; padding: 10px;
margin: 20px auto !important;
cursor: not-allowed; cursor: not-allowed;
pointer-events: none; pointer-events: none;
margin: 20px auto !important;
background: var(--lazyload-background-color);
transition(); transition();
} }
} }

View File

@ -77,7 +77,6 @@ $link-color = darken($default-text-color, 10%);
$copyright-info-color = #CC0033; $copyright-info-color = #CC0033;
$avatar-background-color = #0066CC; $avatar-background-color = #0066CC;
$loading-progress-bar-color = linear-gradient(45deg, #ef0e18, #ff5f00, #eea40b, #1fe708, #00d6d6, #016bd7, #f300f3); $loading-progress-bar-color = linear-gradient(45deg, #ef0e18, #ff5f00, #eea40b, #1fe708, #00d6d6, #016bd7, #f300f3);
$lazyload-background-color = rgba(200, 200, 200, 0.5);
// ======================================================================================== // ========================================================================================
@ -101,7 +100,6 @@ $dark-link-color = lighten($dark-default-text-color, 10%);
$dark-copyright-info-color = darken($copyright-info-color, 20%); $dark-copyright-info-color = darken($copyright-info-color, 20%);
$dark-avatar-background-color = darken($avatar-background-color, 10%); $dark-avatar-background-color = darken($avatar-background-color, 10%);
$dark-loading-progress-bar-color = linear-gradient(45deg, #ea404a, #ea722f, #e9a71f, #67e559, #18ecec, #1b85f1, #ee1dee); $dark-loading-progress-bar-color = linear-gradient(45deg, #ea404a, #ea722f, #e9a71f, #67e559, #18ecec, #1b85f1, #ee1dee);
$dark-lazyload-background-color = rgba(50, 50, 50, 0.5);
// ======================================================================== // ========================================================================
@ -135,7 +133,6 @@ root-color(mode) {
--copyright-info-color: mode == 'light' ? $copyright-info-color : $dark-copyright-info-color; --copyright-info-color: mode == 'light' ? $copyright-info-color : $dark-copyright-info-color;
--avatar-background-color: mode == 'light' ? $avatar-background-color : $dark-avatar-background-color; --avatar-background-color: mode == 'light' ? $avatar-background-color : $dark-avatar-background-color;
--loading-progress-bar-color : mode == 'light' ? $loading-progress-bar-color : $dark-loading-progress-bar-color; --loading-progress-bar-color : mode == 'light' ? $loading-progress-bar-color : $dark-loading-progress-bar-color;
--lazyload-background-color : mode == 'light' ? $lazyload-background-color : $dark-lazyload-background-color;
} }

View File

@ -1,17 +1,60 @@
<!-- By Sam Herbert (@sherb), for everyone. More @ http://goo.gl/7AJzbL --> <?xml version="1.0" encoding="utf-8"?>
<svg width="38" height="38" viewBox="0 0 38 38" xmlns="http://www.w3.org/2000/svg" stroke="#fff"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="margin: auto; background: none; display: block; shape-rendering: auto;" width="80px" height="80px" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid">
<g fill="none" fill-rule="evenodd"> <g transform="translate(80,50)">
<g transform="translate(1 1)" stroke-width="2"> <g transform="rotate(0)">
<circle stroke-opacity=".5" cx="18" cy="18" r="18"/> <circle cx="0" cy="0" r="6" fill="#c8c8c8" fill-opacity="1">
<path d="M36 18c0-9.94-8.06-18-18-18"> <animateTransform attributeName="transform" type="scale" begin="-1.1217948717948718s" values="1.5 1.5;1 1" keyTimes="0;1" dur="1.282051282051282s" repeatCount="indefinite"></animateTransform>
<animateTransform <animate attributeName="fill-opacity" keyTimes="0;1" dur="1.282051282051282s" repeatCount="indefinite" values="1;0" begin="-1.1217948717948718s"></animate>
attributeName="transform" </circle>
type="rotate" </g>
from="0 18 18" </g><g transform="translate(71.21320343559643,71.21320343559643)">
to="360 18 18" <g transform="rotate(45)">
dur="1s" <circle cx="0" cy="0" r="6" fill="#c8c8c8" fill-opacity="0.875">
repeatCount="indefinite"/> <animateTransform attributeName="transform" type="scale" begin="-0.9615384615384615s" values="1.5 1.5;1 1" keyTimes="0;1" dur="1.282051282051282s" repeatCount="indefinite"></animateTransform>
</path> <animate attributeName="fill-opacity" keyTimes="0;1" dur="1.282051282051282s" repeatCount="indefinite" values="1;0" begin="-0.9615384615384615s"></animate>
</g> </circle>
</g> </g>
</svg> </g><g transform="translate(50,80)">
<g transform="rotate(90)">
<circle cx="0" cy="0" r="6" fill="#c8c8c8" fill-opacity="0.75">
<animateTransform attributeName="transform" type="scale" begin="-0.8012820512820512s" values="1.5 1.5;1 1" keyTimes="0;1" dur="1.282051282051282s" repeatCount="indefinite"></animateTransform>
<animate attributeName="fill-opacity" keyTimes="0;1" dur="1.282051282051282s" repeatCount="indefinite" values="1;0" begin="-0.8012820512820512s"></animate>
</circle>
</g>
</g><g transform="translate(28.786796564403577,71.21320343559643)">
<g transform="rotate(135)">
<circle cx="0" cy="0" r="6" fill="#c8c8c8" fill-opacity="0.625">
<animateTransform attributeName="transform" type="scale" begin="-0.641025641025641s" values="1.5 1.5;1 1" keyTimes="0;1" dur="1.282051282051282s" repeatCount="indefinite"></animateTransform>
<animate attributeName="fill-opacity" keyTimes="0;1" dur="1.282051282051282s" repeatCount="indefinite" values="1;0" begin="-0.641025641025641s"></animate>
</circle>
</g>
</g><g transform="translate(20,50.00000000000001)">
<g transform="rotate(180)">
<circle cx="0" cy="0" r="6" fill="#c8c8c8" fill-opacity="0.5">
<animateTransform attributeName="transform" type="scale" begin="-0.4807692307692307s" values="1.5 1.5;1 1" keyTimes="0;1" dur="1.282051282051282s" repeatCount="indefinite"></animateTransform>
<animate attributeName="fill-opacity" keyTimes="0;1" dur="1.282051282051282s" repeatCount="indefinite" values="1;0" begin="-0.4807692307692307s"></animate>
</circle>
</g>
</g><g transform="translate(28.78679656440357,28.786796564403577)">
<g transform="rotate(225)">
<circle cx="0" cy="0" r="6" fill="#c8c8c8" fill-opacity="0.375">
<animateTransform attributeName="transform" type="scale" begin="-0.3205128205128205s" values="1.5 1.5;1 1" keyTimes="0;1" dur="1.282051282051282s" repeatCount="indefinite"></animateTransform>
<animate attributeName="fill-opacity" keyTimes="0;1" dur="1.282051282051282s" repeatCount="indefinite" values="1;0" begin="-0.3205128205128205s"></animate>
</circle>
</g>
</g><g transform="translate(49.99999999999999,20)">
<g transform="rotate(270)">
<circle cx="0" cy="0" r="6" fill="#c8c8c8" fill-opacity="0.25">
<animateTransform attributeName="transform" type="scale" begin="-0.16025641025641024s" values="1.5 1.5;1 1" keyTimes="0;1" dur="1.282051282051282s" repeatCount="indefinite"></animateTransform>
<animate attributeName="fill-opacity" keyTimes="0;1" dur="1.282051282051282s" repeatCount="indefinite" values="1;0" begin="-0.16025641025641024s"></animate>
</circle>
</g>
</g><g transform="translate(71.21320343559643,28.78679656440357)">
<g transform="rotate(315)">
<circle cx="0" cy="0" r="6" fill="#c8c8c8" fill-opacity="0.125">
<animateTransform attributeName="transform" type="scale" begin="0s" values="1.5 1.5;1 1" keyTimes="0;1" dur="1.282051282051282s" repeatCount="indefinite"></animateTransform>
<animate attributeName="fill-opacity" keyTimes="0;1" dur="1.282051282051282s" repeatCount="indefinite" values="1;0" begin="0s"></animate>
</circle>
</g>
</g>
<!-- [ldio] generated by https://loading.io/ --></svg>

Before

Width:  |  Height:  |  Size: 694 B

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -25,7 +25,7 @@ KEEP.initLazyLoad = () => {
img.removeAttribute('loading'); img.removeAttribute('loading');
clearTimeout(loadImageTimeout); clearTimeout(loadImageTimeout);
} }
}, 1000); }, 500);
} }
} }
}); });