vue-intersect
Advanced tools
Comparing version 1.1.6 to 3.0.0
@@ -1,12 +0,3 @@ | ||
import Vue from 'vue'; | ||
var warn = function warn(msg) { | ||
if (!Vue.config.silent) { | ||
console.warn(msg); | ||
} | ||
}; | ||
export default { | ||
name: 'intersect', | ||
abstract: true, | ||
props: { | ||
@@ -35,2 +26,3 @@ threshold: { | ||
}, | ||
emits: ['destroyed', 'enter', 'change', 'leave'], | ||
mounted: function mounted() { | ||
@@ -53,14 +45,18 @@ var _this = this; | ||
var slot = this.$slots.default(); | ||
this.$nextTick(function () { | ||
if (_this.$slots.default && _this.$slots.default.length > 1) { | ||
warn('[VueIntersect] You may only wrap one element in a <intersect> component.'); | ||
} else if (!_this.$slots.default || _this.$slots.default.length < 1) { | ||
warn('[VueIntersect] You must have one child inside a <intersect> component.'); | ||
if (!slot || slot.length < 1) { | ||
console.warn('[VueIntersect] You must have one child inside a <intersect> component.'); | ||
return; | ||
} | ||
_this.observer.observe(_this.$slots.default[0].elm); | ||
slot.filter(function (node) { | ||
return node.el; | ||
}).forEach(function (node) { | ||
_this.observer.observe(node.el); | ||
}); | ||
}); | ||
}, | ||
destroyed: function destroyed() { | ||
unmounted: function unmounted() { | ||
this.$emit('destroyed'); | ||
@@ -70,4 +66,5 @@ this.observer.disconnect(); | ||
render: function render() { | ||
return this.$slots.default ? this.$slots.default[0] : null; | ||
var slot = this.$slots.default(); | ||
return slot || null; | ||
} | ||
}; |
{ | ||
"name": "vue-intersect", | ||
"version": "1.1.6", | ||
"version": "3.0.0", | ||
"description": "A Vue component to add intersection-observer to a Vue component or HTML element.", | ||
@@ -16,6 +16,5 @@ "main": "dist/index.js", | ||
"peerDependencies": { | ||
"vue": "^2.4.2" | ||
"vue": "^3.0.7" | ||
}, | ||
"devDependencies": { | ||
"vue": "^2.4.2", | ||
"babel-cli": "^6.24.1", | ||
@@ -22,0 +21,0 @@ "babel-core": "^6.25.0", |
@@ -1,12 +0,3 @@ | ||
import Vue from 'vue' | ||
const warn = (msg) => { | ||
if (!Vue.config.silent) { | ||
console.warn(msg) | ||
} | ||
} | ||
export default { | ||
name: 'intersect', | ||
abstract: true, | ||
props: { | ||
@@ -29,2 +20,3 @@ threshold: { | ||
}, | ||
emits: [ 'destroyed', 'enter', 'change', 'leave' ], | ||
mounted () { | ||
@@ -45,14 +37,16 @@ this.observer = new IntersectionObserver((entries) => { | ||
const slot = this.$slots.default() | ||
this.$nextTick(() => { | ||
if (this.$slots.default && this.$slots.default.length > 1) { | ||
warn('[VueIntersect] You may only wrap one element in a <intersect> component.') | ||
} else if (!this.$slots.default || this.$slots.default.length < 1) { | ||
warn('[VueIntersect] You must have one child inside a <intersect> component.') | ||
if (!slot || slot.length < 1) { | ||
console.warn('[VueIntersect] You must have one child inside a <intersect> component.') | ||
return | ||
} | ||
this.observer.observe(this.$slots.default[0].elm) | ||
slot.filter(node => node.el).forEach(node => { | ||
this.observer.observe(node.el) | ||
}) | ||
}) | ||
}, | ||
destroyed () { | ||
unmounted () { | ||
this.$emit('destroyed') | ||
@@ -62,4 +56,5 @@ this.observer.disconnect() | ||
render () { | ||
return this.$slots.default ? this.$slots.default[0] : null | ||
const slot = this.$slots.default() | ||
return slot || null | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
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
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
13
10878
10
141
1