lazy loading background image
This commit is contained in:
@@ -55,6 +55,9 @@ installDependencies:
|
|||||||
# - google material icons
|
# - google material icons
|
||||||
if [ ! -d "submodules/material-design-icons" ]; then cd submodules; git clone --filter=tree:0 https://github.com/google/material-design-icons.git; fi
|
if [ ! -d "submodules/material-design-icons" ]; then cd submodules; git clone --filter=tree:0 https://github.com/google/material-design-icons.git; fi
|
||||||
cd submodules/material-design-icons; git fetch; git checkout $(VERSION_GOOGLE_MATERIAL_ICONS);
|
cd submodules/material-design-icons; git fetch; git checkout $(VERSION_GOOGLE_MATERIAL_ICONS);
|
||||||
|
# - lazyload (load small sized placeholder image before loading large full quality image)
|
||||||
|
if [ ! -d "submodules/lazysizes" ]; then cd submodules git clone https://github.com/aFarkas/lazysizes.git; fi
|
||||||
|
cd submodules/lazysizes; git checkout $(VERSION_LAZYSIZES)
|
||||||
|
|
||||||
|
|
||||||
# copy/link all together to get a "distributable" package
|
# copy/link all together to get a "distributable" package
|
||||||
@@ -74,6 +77,8 @@ dist: all
|
|||||||
$(LN) ./submodules/materialize/dist/css/materialize.min.css $(distDir)/httpdocs/ressourcen/css/
|
$(LN) ./submodules/materialize/dist/css/materialize.min.css $(distDir)/httpdocs/ressourcen/css/
|
||||||
$(LN) ./submodules/materialize/dist/css/materialize.min.css.map $(distDir)/httpdocs/ressourcen/css/
|
$(LN) ./submodules/materialize/dist/css/materialize.min.css.map $(distDir)/httpdocs/ressourcen/css/
|
||||||
$(LN) ./submodules/materialize/dist/js/materialize.min.js $(distDir)/httpdocs/ressourcen/js/
|
$(LN) ./submodules/materialize/dist/js/materialize.min.js $(distDir)/httpdocs/ressourcen/js/
|
||||||
|
# - lazysizes
|
||||||
|
$(LN) ./submodules/lazysizes/lazysizes.min.js $(distDir)/httpdocs/ressourcen/js/
|
||||||
|
|
||||||
# page data
|
# page data
|
||||||
mkdir -p $(distDir)/httpdocs/pages/responsive
|
mkdir -p $(distDir)/httpdocs/pages/responsive
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ pandocTemplate = pandocTemplate/materialize-parallax.pandocTemplate
|
|||||||
VERSION_MATERIALIZE = v2.1.1
|
VERSION_MATERIALIZE = v2.1.1
|
||||||
# version of google material icons to use
|
# version of google material icons to use
|
||||||
VERSION_GOOGLE_MATERIAL_ICONS = 4.0.0
|
VERSION_GOOGLE_MATERIAL_ICONS = 4.0.0
|
||||||
|
# version for lazysizes
|
||||||
|
VERSION_LAZYSIZES = 5.3.1
|
||||||
|
|
||||||
# where to put the distribution
|
# where to put the distribution
|
||||||
distDir = ./build/dist/heliohost
|
distDir = ./build/dist/heliohost
|
||||||
|
|||||||
@@ -92,15 +92,22 @@ $wallpapers = [
|
|||||||
</header>
|
</header>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
|
<script>
|
||||||
|
function postload(t){
|
||||||
|
if(t.src !== t.getAttribute('data-src')){
|
||||||
|
t.src = t.getAttribute('data-src');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
<?php
|
<?php
|
||||||
foreach($sections as $idx => $section){
|
foreach($sections as $idx => $section){
|
||||||
echo(
|
echo(
|
||||||
'<div class="parallax-container">'
|
'<div class="parallax-container">'
|
||||||
.'<div class="parallax">'
|
.'<div class="parallax">'
|
||||||
.'<img '
|
.'<img'
|
||||||
.'src="'.$wallpapers[$idx]['src'].'" '
|
. ' class="lazyload" '
|
||||||
// .'data-src="'.$wallpapers[$idx]['data-src'].'" '
|
. ' src="'.$wallpapers[$idx]['src'].'" '
|
||||||
// .'onload="if(this.src !== this.getAttribute(\'data-src\')) this.src=this.getAttribute(\'data-src\');'
|
. ' data-src="'.$wallpapers[$idx]['data-src'].'" '
|
||||||
.'>'
|
.'>'
|
||||||
.'</div>'
|
.'</div>'
|
||||||
.'</div>'
|
.'</div>'
|
||||||
@@ -114,6 +121,7 @@ $wallpapers = [
|
|||||||
|
|
||||||
<!--JavaScript at end of body for optimized loading-->
|
<!--JavaScript at end of body for optimized loading-->
|
||||||
<script type="text/javascript" src="/ressourcen/js/materialize.min.js"></script>
|
<script type="text/javascript" src="/ressourcen/js/materialize.min.js"></script>
|
||||||
|
<script type="text/javascript" src="/ressourcen/js/lazysizes.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
const elems = document.querySelectorAll('.parallax');
|
const elems = document.querySelectorAll('.parallax');
|
||||||
|
|||||||
Reference in New Issue
Block a user