Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@zag-js/interact-outside

Package Overview
Dependencies
Maintainers
1
Versions
821
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zag-js/interact-outside - npm Package Compare versions

Comparing version 0.79.2 to 0.79.3

36

dist/index.js

@@ -83,8 +83,22 @@ 'use strict';

}
function isEventWithinScrollbar(event, target) {
if (!target || !isPointerEvent(event)) return false;
const isScrollableY = target.scrollHeight > target.clientHeight;
const onScrollbarY = isScrollableY && event.clientX > target.clientWidth;
const isScrollableX = target.scrollWidth > target.clientWidth;
const onScrollbarX = isScrollableX && event.clientY > target.clientHeight;
function isPointInRect(rect, point) {
return rect.y <= point.y && point.y <= rect.y + rect.height && rect.x <= point.x && point.x <= rect.x + rect.width;
}
function isEventWithinScrollbar(event, ancestor) {
if (!ancestor || !isPointerEvent(event)) return false;
const isScrollableY = ancestor.scrollHeight > ancestor.clientHeight;
const onScrollbarY = isScrollableY && event.clientX > ancestor.offsetLeft + ancestor.clientWidth;
const isScrollableX = ancestor.scrollWidth > ancestor.clientWidth;
const onScrollbarX = isScrollableX && event.clientY > ancestor.offsetTop + ancestor.clientHeight;
const rect = {
x: ancestor.offsetLeft,
y: ancestor.offsetTop,
width: ancestor.clientWidth + (isScrollableY ? 16 : 0),
height: ancestor.clientHeight + (isScrollableX ? 16 : 0)
};
const point = {
x: event.clientX,
y: event.clientY
};
if (!isPointInRect(rect, point)) return false;
return onScrollbarY || onScrollbarX;

@@ -105,5 +119,9 @@ }

if (isEventPointWithin(node, event)) return false;
if (isEventWithinScrollbar(event, target)) return false;
const scrollParent = domQuery.getNearestOverflowAncestor(node);
if (isEventWithinScrollbar(event, scrollParent)) return false;
const triggerEl = doc.querySelector(`[aria-controls="${node.id}"]`);
if (triggerEl) {
const triggerAncestor = domQuery.getNearestOverflowAncestor(triggerEl);
if (isEventWithinScrollbar(event, triggerAncestor)) return false;
}
const nodeAncestor = domQuery.getNearestOverflowAncestor(node);
if (isEventWithinScrollbar(event, nodeAncestor)) return false;
return !exclude?.(target);

@@ -110,0 +128,0 @@ }

{
"name": "@zag-js/interact-outside",
"version": "0.79.2",
"version": "0.79.3",
"description": "Track interactions or focus outside an element",

@@ -19,5 +19,5 @@ "keywords": [

"dependencies": {
"@zag-js/dom-query": "0.79.2",
"@zag-js/dom-event": "0.79.2",
"@zag-js/utils": "0.79.2"
"@zag-js/dom-query": "0.79.3",
"@zag-js/dom-event": "0.79.3",
"@zag-js/utils": "0.79.3"
},

@@ -24,0 +24,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc