diff options
| author | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-04-18 01:11:37 +0300 |
|---|---|---|
| committer | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-04-18 01:11:37 +0300 |
| commit | 2b6970d33afd75be5bfef951dc3691d492004d43 (patch) | |
| tree | 39eba4206ca0c4cd3fecd5ead95580a74e50f3f9 /public/assets/js/images | |
| parent | 68fc9e55e538e03f94509731ab41a0c8cf96710f (diff) | |
| download | classroom-2b6970d33afd75be5bfef951dc3691d492004d43.tar.gz classroom-2b6970d33afd75be5bfef951dc3691d492004d43.tar.bz2 classroom-2b6970d33afd75be5bfef951dc3691d492004d43.zip | |
admin back-office environment (skeleton); admin categories
Diffstat (limited to 'public/assets/js/images')
| -rw-r--r-- | public/assets/js/images/lazyload.js | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/public/assets/js/images/lazyload.js b/public/assets/js/images/lazyload.js deleted file mode 100644 index 4f954af..0000000 --- a/public/assets/js/images/lazyload.js +++ /dev/null @@ -1,61 +0,0 @@ -$$plugins.define('lazyload', function (element, options) {
- const plugin = this;
- plugin.logger.debug("lazy loading");
- const mutationObserver =
- new MutationObserver(function (mutations) {
- mutations.forEach(function (mutation, index) {
- if (mutation.type === 'childList') {
- mutation.addedNodes.forEach(update);
- }
- });
- }),
- observer =
- new IntersectionObserver(function (entries, self) {
- entries.forEach(function (entry) {
- if (entry.isIntersecting) {
- load(entry.target);
- self.unobserve(entry.target);
- }
- });
- }, options || {
- rootMargin: '0px 0px 1250px 0px',
- threshold: 0
- }),
- elms = element.querySelectorAll('.lazy');
- elms.forEach(elm => observer.observe(elm));
- mutationObserver.observe(element, { childList: true, subtree: true });
-
- function update(element) {
- if (!(element instanceof (HTMLElement))) {
- return;
- }
- const container = element || document;
- if (!container.querySelectorAll) {
- return;
- }
- const elms = container.querySelectorAll('.lazy');
- Array.prototype.forEach.call(elms, (elm) => !elm.getAttribute('data-loaded') && observer.observe(elm));
- }
-
- function load(elm) {
- let i = 0, source, attr, picture = elm.parentElement, sources = picture.querySelectorAll('.lazysrcset');
- if (sources.length) {
- for (; i < sources.length; i++) {
- source = sources[i];
- attr = source.getAttribute('data-srcset');
- if (attr) {
- source.srcset = source.getAttribute('data-srcset');
- }
- }
- }
-
- if (!elm.getAttribute('data-loaded') && elm.getAttribute('data-src')) {
- elm.src = elm.getAttribute('data-src');
- elm.setAttribute('data-loaded', true);
- }
- }
-
- return {
- update: update
- };
-});
\ No newline at end of file |
