v-lazy-image
Advanced tools
Comparing version 1.4.0 to 2.0.0
@@ -1,99 +0,1 @@ | ||
/** | ||
* v-lazy-image v1.4.0 | ||
* (c) 2020 Alex Jover Morales <alexjovermorales@gmail.com> | ||
* @license MIT | ||
*/ | ||
var VLazyImageComponent = { | ||
props: { | ||
src: { | ||
type: String, | ||
required: true | ||
}, | ||
srcPlaceholder: { | ||
type: String, | ||
default: "//:0" | ||
}, | ||
srcset: { | ||
type: String | ||
}, | ||
intersectionOptions: { | ||
type: Object, | ||
default: function () { return ({}); } | ||
}, | ||
usePicture: { | ||
type: Boolean, | ||
default: false | ||
} | ||
}, | ||
inheritAttrs: false, | ||
data: function () { return ({ observer: null, intersected: false, loaded: false }); }, | ||
computed: { | ||
srcImage: function srcImage() { | ||
return this.intersected && this.src ? this.src : this.srcPlaceholder; | ||
}, | ||
srcsetImage: function srcsetImage() { | ||
return this.intersected && this.srcset ? this.srcset : false; | ||
} | ||
}, | ||
methods: { | ||
load: function load() { | ||
if (this.$el.getAttribute("src") !== this.srcPlaceholder) { | ||
this.loaded = true; | ||
this.$emit("load"); | ||
} | ||
} | ||
}, | ||
render: function render(h) { | ||
var img = h("img", { | ||
attrs: { | ||
src: this.srcImage, | ||
srcset: this.srcsetImage | ||
}, | ||
domProps: this.$attrs, | ||
class: { | ||
"v-lazy-image": true, | ||
"v-lazy-image-loaded": this.loaded | ||
}, | ||
on: { load: this.load } | ||
}); | ||
if (this.usePicture) { | ||
return h( | ||
"picture", | ||
{ on: { load: this.load } }, | ||
this.intersected ? [this.$slots.default, img] : [img] | ||
); | ||
} else { | ||
return img; | ||
} | ||
}, | ||
mounted: function mounted() { | ||
var this$1 = this; | ||
if ("IntersectionObserver" in window) { | ||
this.observer = new IntersectionObserver(function (entries) { | ||
var image = entries[0]; | ||
if (image.isIntersecting) { | ||
this$1.intersected = true; | ||
this$1.observer.disconnect(); | ||
this$1.$emit("intersect"); | ||
} | ||
}, this.intersectionOptions); | ||
this.observer.observe(this.$el); | ||
} | ||
}, | ||
destroyed: function destroyed() { | ||
if ("IntersectionObserver" in window) { | ||
this.observer.disconnect(); | ||
} | ||
} | ||
}; | ||
var VLazyImagePlugin = { | ||
install: function (Vue, opts) { | ||
Vue.component("VLazyImage", VLazyImageComponent); | ||
} | ||
}; | ||
export { VLazyImagePlugin }; | ||
export default VLazyImageComponent; | ||
var e=Object.defineProperty,r=Object.defineProperties,t=Object.getOwnPropertyDescriptors,s=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable,c=(r,t,s)=>t in r?e(r,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[t]=s;import{ref as i,reactive as a,computed as l,onMounted as d,onBeforeUnmount as u,h as p}from"vue";var v={props:{src:{type:String,required:!0},srcPlaceholder:{type:String,default:"data:,"},srcset:{type:String},intersectionOptions:{type:Object,default:()=>({})},usePicture:{type:Boolean,default:!1}},inheritAttrs:!1,setup(e,{attrs:v,slots:b,emit:f}){const y=i(null),O=a({observer:null,intersected:!1,loaded:!1}),g=l((()=>O.intersected&&e.src?e.src:e.srcPlaceholder)),P=l((()=>!(!O.intersected||!e.srcset)&&e.srcset)),m=()=>{y.value.getAttribute("src")!==e.srcPlaceholder&&(O.loaded=!0,f("load"))},w=()=>f("error",y.value);return d((()=>{"IntersectionObserver"in window&&(O.observer=new IntersectionObserver((e=>{e[0].isIntersecting&&(O.intersected=!0,O.observer.disconnect(),f("intersect"))}),e.intersectionOptions),O.observer.observe(y.value))})),u((()=>{"IntersectionObserver"in window&&O.observer.disconnect()})),()=>{const i=p("img",(a=((e,r)=>{for(var t in r||(r={}))o.call(r,t)&&c(e,t,r[t]);if(s)for(var t of s(r))n.call(r,t)&&c(e,t,r[t]);return e})({ref:y,src:g.value,srcset:P.value||null},v),l={class:[v.class,"v-lazy-image",{"v-lazy-image-loaded":O.loaded}],onLoad:m,onError:w},r(a,t(l))));var a,l;return e.usePicture?p("picture",{ref:y,onLoad:m},O.intersected?[b.default,i]:[i]):i}}};export{v as default}; |
{ | ||
"name": "v-lazy-image", | ||
"version": "1.4.0", | ||
"description": "A Vue.js component to lazy load images using the Intersection Observer.", | ||
"main": "dist/v-lazy-image.cjs.js", | ||
"module": "dist/v-lazy-image.es.js", | ||
"unpkg": "dist/v-lazy-image.js", | ||
"browser": "dist/v-lazy-image.js", | ||
"author": { | ||
"name": "Alex Jover Morales", | ||
"email": "alexjovermorales@gmail.com" | ||
}, | ||
"version": "2.0.0", | ||
"scripts": { | ||
"build": "rollit", | ||
"prepublishOnly": "npm run build", | ||
"test": "jest" | ||
"build": "vite build && vite build -m v2", | ||
"demo": "vite", | ||
"test": "npm run test:unit && npm run test:e2e", | ||
"test:unit": "jest __tests__", | ||
"test:e2e": "cypress run-ct" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/alexjoverm/v-lazy-image.git" | ||
"devDependencies": { | ||
"@babel/core": "^7.15.0", | ||
"@cypress/vite-dev-server": "^2.0.7", | ||
"@cypress/vue": "^3.0.3", | ||
"@vitejs/plugin-vue": "^1.3.0", | ||
"@vue/babel-preset-app": "^4.5.13", | ||
"@vue/compiler-sfc": "^3.2.1", | ||
"@vue/test-utils": "next", | ||
"babel-jest": "^26.6.3", | ||
"cypress": "^8.3.0", | ||
"jest": "^26.6.3", | ||
"vite": "^2.4.4", | ||
"vue": "^3.0.0", | ||
"vue-jest": "next" | ||
}, | ||
"keywords": [ | ||
"vue", | ||
"js", | ||
"lazy", | ||
"load", | ||
"image", | ||
"intersection", | ||
"observer" | ||
"files": [ | ||
"dist", | ||
"v2" | ||
], | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/alexjoverm/v-lazy-image/issues" | ||
"main": "./dist/v-lazy-image.umd.js", | ||
"module": "./dist/v-lazy-image.es.js", | ||
"exports": { | ||
".": { | ||
"import": "./dist/v-lazy-image.es.js", | ||
"require": "./dist/v-lazy-image.umd.js" | ||
}, | ||
"./v2": { | ||
"import": "./v2/v-lazy-image.es.js", | ||
"require": "./v2/v-lazy-image.umd.js" | ||
} | ||
}, | ||
"homepage": "https://github.com/alexjoverm/v-lazy-image#readme", | ||
"devDependencies": { | ||
"@vue/test-utils": "^1.0.0-beta.28", | ||
"babel-core": "^6.26.3", | ||
"babel-jest": "^23.6.0", | ||
"babel-preset-env": "^1.7.0", | ||
"intersection-observer": "^0.5.1", | ||
"jest": "^23.6.0", | ||
"jest-serializer-vue": "^2.0.2", | ||
"rollit": "0.0.8" | ||
}, | ||
"peerDependencies": { | ||
"vue": "^2.0.0" | ||
}, | ||
"jest": { | ||
"moduleFileExtensions": [ | ||
"js" | ||
"js", | ||
"json", | ||
"vue" | ||
], | ||
"snapshotSerializers": [ | ||
"jest-serializer-vue" | ||
] | ||
"transform": { | ||
"^.+\\.js$": "babel-jest", | ||
"^.+\\.vue$": "vue-jest" | ||
} | ||
} | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
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
0
7493
13
5
1
26
2
2
1
0
1
1