@alpinejs/intersect
Advanced tools
Comparing version 3.2.3 to 3.2.4
(() => { | ||
// packages/intersect/src/index.js | ||
function src_default(Alpine) { | ||
Alpine.directive("intersect", (el, {expression, modifiers}, {evaluateLater, cleanup}) => { | ||
Alpine.directive("intersect", (el, {value, expression, modifiers}, {evaluateLater, cleanup}) => { | ||
let evaluate = evaluateLater(expression); | ||
let observer = new IntersectionObserver((entries) => { | ||
entries.forEach((entry) => { | ||
if (entry.intersectionRatio === 0) | ||
if (!entry.isIntersecting && value === "enter" || entry.isIntersecting && value === "leave" || entry.intersectionRatio === 0 && !value) | ||
return; | ||
@@ -10,0 +10,0 @@ evaluate(); |
@@ -1,1 +0,1 @@ | ||
(()=>{function n(t){t.directive("intersect",(i,{expression:r,modifiers:c},{evaluateLater:o,cleanup:s})=>{let d=o(r),e=new IntersectionObserver(l=>{l.forEach(a=>{a.intersectionRatio!==0&&(d(),c.includes("once")&&e.disconnect())})});e.observe(i),s(()=>{e.disconnect()})})}document.addEventListener("alpine:init",()=>{window.Alpine.plugin(n)});})(); | ||
(()=>{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)});})(); |
@@ -16,7 +16,7 @@ var __defProp = Object.defineProperty; | ||
function src_default(Alpine) { | ||
Alpine.directive("intersect", (el, {expression, modifiers}, {evaluateLater, cleanup}) => { | ||
Alpine.directive("intersect", (el, {value, expression, modifiers}, {evaluateLater, cleanup}) => { | ||
let evaluate = evaluateLater(expression); | ||
let observer = new IntersectionObserver((entries) => { | ||
entries.forEach((entry) => { | ||
if (entry.intersectionRatio === 0) | ||
if (!entry.isIntersecting && value === "enter" || entry.isIntersecting && value === "leave" || entry.intersectionRatio === 0 && !value) | ||
return; | ||
@@ -23,0 +23,0 @@ evaluate(); |
// packages/intersect/src/index.js | ||
function src_default(Alpine) { | ||
Alpine.directive("intersect", (el, {expression, modifiers}, {evaluateLater, cleanup}) => { | ||
Alpine.directive("intersect", (el, {value, expression, modifiers}, {evaluateLater, cleanup}) => { | ||
let evaluate = evaluateLater(expression); | ||
let observer = new IntersectionObserver((entries) => { | ||
entries.forEach((entry) => { | ||
if (entry.intersectionRatio === 0) | ||
if (!entry.isIntersecting && value === "enter" || entry.isIntersecting && value === "leave" || entry.intersectionRatio === 0 && !value) | ||
return; | ||
@@ -9,0 +9,0 @@ evaluate(); |
{ | ||
"name": "@alpinejs/intersect", | ||
"version": "3.2.3", | ||
"version": "3.2.4", | ||
"description": "Trigger JavaScript when an element enters the viewport", | ||
@@ -5,0 +5,0 @@ "author": "Caleb Porzio", |
export default function (Alpine) { | ||
Alpine.directive('intersect', (el, { expression, modifiers }, { evaluateLater, cleanup }) => { | ||
Alpine.directive('intersect', (el, { value, expression, modifiers }, { evaluateLater, cleanup }) => { | ||
let evaluate = evaluateLater(expression) | ||
@@ -7,3 +7,7 @@ | ||
entries.forEach(entry => { | ||
if (entry.intersectionRatio === 0) return | ||
if ( | ||
! entry.isIntersecting && value === 'enter' | ||
|| entry.isIntersecting && value === 'leave' | ||
|| entry.intersectionRatio === 0 && ! value | ||
) return | ||
@@ -10,0 +14,0 @@ evaluate() |
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
4415
106