@alpinejs/intersect
Advanced tools
Comparing version 3.3.1 to 3.3.2
@@ -6,2 +6,5 @@ (() => { | ||
let evaluate = evaluateLater(expression); | ||
let options = { | ||
threshold: getThreshhold(modifiers) | ||
}; | ||
let observer = new IntersectionObserver((entries) => { | ||
@@ -14,3 +17,3 @@ entries.forEach((entry) => { | ||
}); | ||
}); | ||
}, options); | ||
observer.observe(el); | ||
@@ -22,2 +25,9 @@ cleanup(() => { | ||
} | ||
function getThreshhold(modifiers) { | ||
if (modifiers.includes("full")) | ||
return 0.99; | ||
if (modifiers.includes("half")) | ||
return 0.5; | ||
return 0; | ||
} | ||
@@ -24,0 +34,0 @@ // packages/intersect/builds/cdn.js |
@@ -1,1 +0,1 @@ | ||
(()=>{function i(r){r.directive("intersect",(c,{value:e,expression:s,modifiers:o},{evaluateLater:d,cleanup:l})=>{let a=d(s),n=new IntersectionObserver(f=>{f.forEach(t=>{!t.isIntersecting&&e==="enter"||t.isIntersecting&&e==="leave"||t.intersectionRatio===0&&!e||(a(),o.includes("once")&&n.disconnect())})});n.observe(c),l(()=>{n.disconnect()})})}document.addEventListener("alpine:init",()=>{window.Alpine.plugin(i)});})(); | ||
(()=>{function c(e){e.directive("intersect",(s,{value:n,expression:o,modifiers:r},{evaluateLater:l,cleanup:d})=>{let u=l(o),f={threshold:h(r)},t=new IntersectionObserver(a=>{a.forEach(i=>{!i.isIntersecting&&n==="enter"||i.isIntersecting&&n==="leave"||i.intersectionRatio===0&&!n||(u(),r.includes("once")&&t.disconnect())})},f);t.observe(s),d(()=>{t.disconnect()})})}function h(e){return e.includes("full")?.99:e.includes("half")?.5:0}document.addEventListener("alpine:init",()=>{window.Alpine.plugin(c)});})(); |
@@ -18,2 +18,5 @@ var __defProp = Object.defineProperty; | ||
let evaluate = evaluateLater(expression); | ||
let options = { | ||
threshold: getThreshhold(modifiers) | ||
}; | ||
let observer = new IntersectionObserver((entries) => { | ||
@@ -26,3 +29,3 @@ entries.forEach((entry) => { | ||
}); | ||
}); | ||
}, options); | ||
observer.observe(el); | ||
@@ -34,4 +37,11 @@ cleanup(() => { | ||
} | ||
function getThreshhold(modifiers) { | ||
if (modifiers.includes("full")) | ||
return 0.99; | ||
if (modifiers.includes("half")) | ||
return 0.5; | ||
return 0; | ||
} | ||
// packages/intersect/builds/module.js | ||
var module_default = src_default; |
@@ -5,2 +5,5 @@ // packages/intersect/src/index.js | ||
let evaluate = evaluateLater(expression); | ||
let options = { | ||
threshold: getThreshhold(modifiers) | ||
}; | ||
let observer = new IntersectionObserver((entries) => { | ||
@@ -13,3 +16,3 @@ entries.forEach((entry) => { | ||
}); | ||
}); | ||
}, options); | ||
observer.observe(el); | ||
@@ -21,2 +24,9 @@ cleanup(() => { | ||
} | ||
function getThreshhold(modifiers) { | ||
if (modifiers.includes("full")) | ||
return 0.99; | ||
if (modifiers.includes("half")) | ||
return 0.5; | ||
return 0; | ||
} | ||
@@ -23,0 +33,0 @@ // packages/intersect/builds/module.js |
{ | ||
"name": "@alpinejs/intersect", | ||
"version": "3.3.1", | ||
"version": "3.3.2", | ||
"description": "Trigger JavaScript when an element enters the viewport", | ||
@@ -5,0 +5,0 @@ "author": "Caleb Porzio", |
@@ -0,1 +1,2 @@ | ||
export default function (Alpine) { | ||
@@ -5,2 +6,6 @@ Alpine.directive('intersect', (el, { value, expression, modifiers }, { evaluateLater, cleanup }) => { | ||
let options = { | ||
threshold: getThreshhold(modifiers), | ||
} | ||
let observer = new IntersectionObserver(entries => { | ||
@@ -18,3 +23,3 @@ entries.forEach(entry => { | ||
}) | ||
}) | ||
}, options) | ||
@@ -28,1 +33,8 @@ observer.observe(el) | ||
} | ||
function getThreshhold(modifiers) { | ||
if (modifiers.includes('full')) return 0.99 | ||
if (modifiers.includes('half')) return 0.5 | ||
return 0 | ||
} |
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
5453
144