vue-lazy-loading
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -0,0 +0,0 @@ import { LazyOptions } from '../types/index.js'; |
@@ -0,0 +0,0 @@ import { getVueVersion, LazyCore, error } from './util.js'; |
@@ -0,0 +0,0 @@ import { LazyOptions, LazyBinding } from '../types/index.js'; |
@@ -96,17 +96,16 @@ var LazyCore = (function () { | ||
entries.forEach(function (item) { | ||
var _a, _b, _c, _d; | ||
var _a; | ||
if (item.isIntersecting) { | ||
var src = (_a = item.target.dataset) === null || _a === void 0 ? void 0 : _a.src; | ||
var srcset = (_b = item.target.dataset) === null || _b === void 0 ? void 0 : _b.srcset; | ||
var bg = (_c = item.target.dataset) === null || _c === void 0 ? void 0 : _c.bg; | ||
var el = item.target; | ||
var _b = getDataset(el), src = _b.src, srcset = _b.srcset, bg = _b.bg; | ||
if (src) { | ||
item.target.src = src; | ||
el.src = src; | ||
} | ||
if (srcset) { | ||
item.target.srcset = srcset; | ||
el.srcset = srcset; | ||
} | ||
if (bg) { | ||
item.target.style.backgroundImage = "url(" + bg + ")"; | ||
el.style.backgroundImage = "url(" + bg + ")"; | ||
} | ||
(_d = _this.io) === null || _d === void 0 ? void 0 : _d.unobserve(item.target); | ||
(_a = _this.io) === null || _a === void 0 ? void 0 : _a.unobserve(item.target); | ||
} | ||
@@ -121,2 +120,21 @@ }); | ||
export { LazyCore }; | ||
function getDataset(el) { | ||
if (el.dataset) { | ||
return el.dataset; | ||
} | ||
else { | ||
var obj = {}; | ||
for (var i = 0; i < el.attributes.length; i++) { | ||
var name_1 = el.attributes[i].nodeName; | ||
if (/^data-\w+$/.test(name_1)) { | ||
var key = name_1.split('-')[1]; | ||
var value = el.attributes[i].nodeValue || undefined; | ||
if (['src', 'srcset', 'bg'].indexOf(key) !== -1) { | ||
obj[key] = value; | ||
} | ||
} | ||
} | ||
return obj; | ||
} | ||
} | ||
export function getVueVersion(Vue) { | ||
@@ -123,0 +141,0 @@ return Number(Vue.version.split('.')[0]); |
{ | ||
"name": "vue-lazy-loading", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "a vue plugin to better supporting lazy loading for image and iframe", | ||
"main": "dist/index.js", | ||
"typings": "dist/index.d.ts", | ||
"type": "module", | ||
"types": "dist/index.d.ts", | ||
"scripts": { | ||
"dev": "tsc -w" | ||
"dev": "tsc -w", | ||
"build": "tsc -b" | ||
}, | ||
@@ -10,0 +12,0 @@ "repository": { |
@@ -33,3 +33,3 @@ # vue-lazy-loading | ||
``` vue | ||
``` html | ||
<template> | ||
@@ -107,5 +107,1 @@ <!-- Setting a fixed size is better for browser loading --> | ||
[MIT](http://opensource.org/licenses/MIT) | ||
## Keywords | ||
vue lazy img iframe loading background-image |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Yes
12054
8
208
106