UNPKG

vuetify-wcag

Version:

VuetifyJS but then WCAG/A11Y compatible

50 lines (42 loc) 1.5 kB
function inserted(el, binding, vnode) { if (typeof window === 'undefined' || !('IntersectionObserver' in window)) return; const modifiers = binding.modifiers || {}; const value = binding.value; const { handler, options } = typeof value === 'object' ? value : { handler: value, options: {} }; const observer = new IntersectionObserver((entries = [], observer) => { var _a; const _observe = (_a = el._observe) === null || _a === void 0 ? void 0 : _a[vnode.context._uid]; if (!_observe) return; // Just in case, should never fire const isIntersecting = entries.some(entry => entry.isIntersecting); // If is not quiet or has already been // initted, invoke the user callback if (handler && (!modifiers.quiet || _observe.init) && (!modifiers.once || isIntersecting || _observe.init)) { handler(entries, observer, isIntersecting); } if (isIntersecting && modifiers.once) unbind(el, binding, vnode);else _observe.init = true; }, options); el._observe = Object(el._observe); el._observe[vnode.context._uid] = { init: false, observer }; observer.observe(el); } function unbind(el, binding, vnode) { var _a; const observe = (_a = el._observe) === null || _a === void 0 ? void 0 : _a[vnode.context._uid]; if (!observe) return; observe.observer.unobserve(el); delete el._observe[vnode.context._uid]; } export const Intersect = { inserted, unbind }; export default Intersect; //# sourceMappingURL=index.js.map