Skip to content

Commit

Permalink
Merge branch 'development' with 2 new demos
Browse files Browse the repository at this point in the history
  • Loading branch information
verlok committed Jun 4, 2021
2 parents 4426bae + ab3b175 commit c7beeb5
Show file tree
Hide file tree
Showing 2 changed files with 187 additions and 111 deletions.
174 changes: 63 additions & 111 deletions demos/video.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
<html>
<head lang="en">
<meta charset="UTF-8" />
<title>
Lazy video - Lazyload demos
</title>
<title>Lazy video - Lazyload demos</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
ul,
Expand All @@ -13,115 +11,68 @@
margin: 0;
padding: 0;
}
.viewport-height {
min-height: calc(100vh + 300px);
}
</style>
</head>

<body>
<h1>Lazy video demo</h1>
<div id="results1" class="results">
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<p>Scroll down</p>
<h2>Preload = metadata</h2>
<video
class="lazy"
autoplay
controls
preload="auto"
width="620"
data-src="https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4"
data-poster="https://peach.blender.org/wp-content/uploads/title_anouncement.jpg?x11217"
>
<source
type="video/mp4"
data-src="https://archive.org/download/ElephantsDream/ed_1024_512kb.mp4"
/>
<source
type="video/ogg"
data-src="https://archive.org/download/ElephantsDream/ed_hd.ogv"
/>
<source
type="video/avi"
data-src="https://archive.org/download/ElephantsDream/ed_hd.avi"
/>
</video>
<h2>Preload = none</h2>
<video
class="lazy"
preload="none"
autoplay
controls
width="620"
data-src="https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4"
data-poster="https://peach.blender.org/wp-content/uploads/title_anouncement.jpg?x11217"
>
<source
type="video/mp4"
data-src="https://archive.org/download/ElephantsDream/ed_1024_512kb.mp4"
/>
<source
type="video/ogg"
data-src="https://archive.org/download/ElephantsDream/ed_hd.ogv"
/>
<source
type="video/avi"
data-src="https://archive.org/download/ElephantsDream/ed_hd.avi"
/>
</video>
<h2>Preload = metadata</h2>
<video
class="lazy"
preload="metadata"
autoplay
controls
width="620"
data-src="https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4"
data-poster="https://peach.blender.org/wp-content/uploads/title_anouncement.jpg?x11217"
>
<source
type="video/mp4"
data-src="https://archive.org/download/ElephantsDream/ed_1024_512kb.mp4"
/>
<source
type="video/ogg"
data-src="https://archive.org/download/ElephantsDream/ed_hd.ogv"
/>
<source
type="video/avi"
data-src="https://archive.org/download/ElephantsDream/ed_hd.avi"
/>
</video>
</div>
<h1>Lazy video demo - NO autoplay</h1>
<p>👇🏼 Scroll down to see the lazy videos 👇🏼</p>
<div class="viewport-height"></div>

<h2>Preload = none</h2>
<video
class="lazy"
controls
preload="none"
width="620"
data-src="https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4"
data-poster="https://peach.blender.org/wp-content/uploads/title_anouncement.jpg?x11217"
>
<source
type="video/mp4"
data-src="https://archive.org/download/ElephantsDream/ed_1024_512kb.mp4"
/>
<source type="video/ogg" data-src="https://archive.org/download/ElephantsDream/ed_hd.ogv" />
<source type="video/avi" data-src="https://archive.org/download/ElephantsDream/ed_hd.avi" />
</video>

<h2>Preload = metadata</h2>
<video
class="lazy"
preload="metadata"
controls
width="620"
data-src="https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4"
data-poster="https://peach.blender.org/wp-content/uploads/title_anouncement.jpg?x11217"
>
<source
type="video/mp4"
data-src="https://archive.org/download/ElephantsDream/ed_1024_512kb.mp4"
/>
<source type="video/ogg" data-src="https://archive.org/download/ElephantsDream/ed_hd.ogv" />
<source type="video/avi" data-src="https://archive.org/download/ElephantsDream/ed_hd.avi" />
</video>

<h2>Preload = auto</h2>
<video
class="lazy"
preload="auto"
controls
width="620"
data-src="https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4"
data-poster="https://peach.blender.org/wp-content/uploads/title_anouncement.jpg?x11217"
>
<source
type="video/mp4"
data-src="https://archive.org/download/ElephantsDream/ed_1024_512kb.mp4"
/>
<source type="video/ogg" data-src="https://archive.org/download/ElephantsDream/ed_hd.ogv" />
<source type="video/avi" data-src="https://archive.org/download/ElephantsDream/ed_hd.avi" />
</video>

<script src="../dist/lazyload.min.js"></script>
<script>
(function () {
Expand All @@ -143,8 +94,7 @@ <h2>Preload = metadata</h2>
};
var callback_error = function (element) {
logElementEvent("💀 ERROR", element);
element.src =
"https://via.placeholder.com/440x560/?text=Error+Placeholder";
element.src = "https://via.placeholder.com/440x560/?text=Error+Placeholder";
};
var callback_finish = function () {
logElementEvent("✔️ FINISHED", document.documentElement);
Expand All @@ -161,7 +111,9 @@ <h2>Preload = metadata</h2>
callback_loading: callback_loading,
callback_loaded: callback_loaded,
callback_error: callback_error,
callback_finish: callback_finish
callback_finish: callback_finish,
// For debugging purposes
threshold: 0
});
})();
</script>
Expand Down
124 changes: 124 additions & 0 deletions demos/video_autoplay.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8" />
<title>Lazy autoplay video - Lazyload demos</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
ul,
li {
list-style-type: none;
margin: 0;
padding: 0;
}
.viewport-height {
min-height: calc(100vh + 300px);
}
</style>
</head>

<body>
<h1>Lazy video demo, with autoplay</h1>
<p>👇🏼 Scroll down to see the lazy videos 👇🏼</p>
<div class="viewport-height"></div>

<h2>Preload = none</h2>
<video
class="lazy"
controls
autoplay
preload="none"
width="620"
data-src="https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4"
data-poster="https://peach.blender.org/wp-content/uploads/title_anouncement.jpg?x11217"
>
<source
type="video/mp4"
data-src="https://archive.org/download/ElephantsDream/ed_1024_512kb.mp4"
/>
<source type="video/ogg" data-src="https://archive.org/download/ElephantsDream/ed_hd.ogv" />
<source type="video/avi" data-src="https://archive.org/download/ElephantsDream/ed_hd.avi" />
</video>

<h2>Preload = metadata</h2>
<video
class="lazy"
preload="metadata"
controls
autoplay
width="620"
data-src="https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4"
data-poster="https://peach.blender.org/wp-content/uploads/title_anouncement.jpg?x11217"
>
<source
type="video/mp4"
data-src="https://archive.org/download/ElephantsDream/ed_1024_512kb.mp4"
/>
<source type="video/ogg" data-src="https://archive.org/download/ElephantsDream/ed_hd.ogv" />
<source type="video/avi" data-src="https://archive.org/download/ElephantsDream/ed_hd.avi" />
</video>

<h2>Preload = auto</h2>
<video
class="lazy"
preload="auto"
controls
autoplay
width="620"
data-src="https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4"
data-poster="https://peach.blender.org/wp-content/uploads/title_anouncement.jpg?x11217"
>
<source
type="video/mp4"
data-src="https://archive.org/download/ElephantsDream/ed_1024_512kb.mp4"
/>
<source type="video/ogg" data-src="https://archive.org/download/ElephantsDream/ed_hd.ogv" />
<source type="video/avi" data-src="https://archive.org/download/ElephantsDream/ed_hd.avi" />
</video>

<script src="../dist/lazyload.min.js"></script>
<script>
(function () {
function logElementEvent(eventName, element) {
console.log(Date.now(), eventName, element.getAttribute("data-src"));
}

var callback_enter = function (element) {
logElementEvent("🔑 ENTERED", element);
};
var callback_exit = function (element) {
logElementEvent("🚪 EXITED", element);
};
var callback_loading = function (element) {
logElementEvent("⌚ LOADING", element);
};
var callback_loaded = function (element) {
logElementEvent("👍 LOADED", element);
};
var callback_error = function (element) {
logElementEvent("💀 ERROR", element);
element.src = "https://via.placeholder.com/440x560/?text=Error+Placeholder";
};
var callback_finish = function () {
logElementEvent("✔️ FINISHED", document.documentElement);
};
var callback_cancel = function (element) {
logElementEvent("🔥 CANCEL", element);
};

ll = new LazyLoad({
// Assign the callbacks defined above
callback_enter: callback_enter,
callback_exit: callback_exit,
callback_cancel: callback_cancel,
callback_loading: callback_loading,
callback_loaded: callback_loaded,
callback_error: callback_error,
callback_finish: callback_finish,
// For debugging purposes
threshold: 0
});
})();
</script>
</body>
</html>

0 comments on commit c7beeb5

Please sign in to comment.