@alpinejs/intersect
Advanced tools
Comparing version 3.9.2 to 3.9.3
@@ -29,3 +29,10 @@ (() => { | ||
return 0.5; | ||
return 0; | ||
if (!modifiers.includes("threshold")) | ||
return 0; | ||
let threshhold = modifiers[modifiers.indexOf("threshold") + 1]; | ||
if (threshhold === "1") | ||
return 1; | ||
if (threshhold === "0") | ||
return 0; | ||
return Number(`.${threshhold}`); | ||
} | ||
@@ -32,0 +39,0 @@ function getLengthValue(rawValue) { |
@@ -1,1 +0,1 @@ | ||
(()=>{function l(e){e.directive("intersect",(t,{value:i,expression:o,modifiers:n},{evaluateLater:r,cleanup:u})=>{let s=r(o),a={rootMargin:h(n),threshold:p(n)},c=new IntersectionObserver(d=>{d.forEach(f=>{f.isIntersecting!==(i==="leave")&&(s(),n.includes("once")&&c.disconnect())})},a);c.observe(t),u(()=>{c.disconnect()})})}function p(e){return e.includes("full")?.99:e.includes("half")?.5:0}function x(e){let t=e.match(/^(-?[0-9]+)(px|%)?$/);return t?t[1]+(t[2]||"px"):void 0}function h(e){let t="margin",i="0px 0px 0px 0px",o=e.indexOf(t);if(o===-1)return i;let n=[];for(let r=1;r<5;r++)n.push(x(e[o+r]||""));return n=n.filter(r=>r!==void 0),n.length?n.join(" ").trim():i}document.addEventListener("alpine:init",()=>{window.Alpine.plugin(l)});})(); | ||
(()=>{function c(e){e.directive("intersect",(t,{value:i,expression:l,modifiers:n},{evaluateLater:r,cleanup:o})=>{let s=r(l),h={rootMargin:p(n),threshold:f(n)},u=new IntersectionObserver(d=>{d.forEach(a=>{a.isIntersecting!==(i==="leave")&&(s(),n.includes("once")&&u.disconnect())})},h);u.observe(t),o(()=>{u.disconnect()})})}function f(e){if(e.includes("full"))return .99;if(e.includes("half"))return .5;if(!e.includes("threshold"))return 0;let t=e[e.indexOf("threshold")+1];return t==="1"?1:t==="0"?0:Number(`.${t}`)}function x(e){let t=e.match(/^(-?[0-9]+)(px|%)?$/);return t?t[1]+(t[2]||"px"):void 0}function p(e){let t="margin",i="0px 0px 0px 0px",l=e.indexOf(t);if(l===-1)return i;let n=[];for(let r=1;r<5;r++)n.push(x(e[l+r]||""));return n=n.filter(r=>r!==void 0),n.length?n.join(" ").trim():i}document.addEventListener("alpine:init",()=>{window.Alpine.plugin(c)});})(); |
@@ -41,3 +41,10 @@ var __defProp = Object.defineProperty; | ||
return 0.5; | ||
return 0; | ||
if (!modifiers.includes("threshold")) | ||
return 0; | ||
let threshhold = modifiers[modifiers.indexOf("threshold") + 1]; | ||
if (threshhold === "1") | ||
return 1; | ||
if (threshhold === "0") | ||
return 0; | ||
return Number(`.${threshhold}`); | ||
} | ||
@@ -44,0 +51,0 @@ function getLengthValue(rawValue) { |
@@ -28,3 +28,10 @@ // packages/intersect/src/index.js | ||
return 0.5; | ||
return 0; | ||
if (!modifiers.includes("threshold")) | ||
return 0; | ||
let threshhold = modifiers[modifiers.indexOf("threshold") + 1]; | ||
if (threshhold === "1") | ||
return 1; | ||
if (threshhold === "0") | ||
return 0; | ||
return Number(`.${threshhold}`); | ||
} | ||
@@ -31,0 +38,0 @@ function getLengthValue(rawValue) { |
{ | ||
"name": "@alpinejs/intersect", | ||
"version": "3.9.2", | ||
"version": "3.9.3", | ||
"description": "Trigger JavaScript when an element enters the viewport", | ||
@@ -5,0 +5,0 @@ "author": "Caleb Porzio", |
@@ -32,4 +32,10 @@ export default function (Alpine) { | ||
if (modifiers.includes('half')) return 0.5 | ||
if (! modifiers.includes('threshold')) return 0 | ||
return 0 | ||
let threshhold = modifiers[modifiers.indexOf('threshold') + 1] | ||
if (threshhold === '1') return 1 | ||
if (threshhold === '0') return 0 | ||
return Number(`.${threshhold}`) | ||
} | ||
@@ -36,0 +42,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
9137
243