@udixio/ui-react 2.8.0 → 2.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"block-scroll.effect.d.ts","sourceRoot":"","sources":["../../../src/lib/effects/block-scroll.effect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAEjD,KAAK,YAAY,GACb;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,OAAO,GAAG,OAAO,GAAG,UAAU,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,KAAK,CAAC;CACtB,GACD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEN,KAAK,gBAAgB,GAAG;IACtB,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,IAAI,CAAC;IACvC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,EAAE,EAAE,WAAW,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAqJlD,CAAC"}
1
+ {"version":3,"file":"block-scroll.effect.d.ts","sourceRoot":"","sources":["../../../src/lib/effects/block-scroll.effect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAEjD,KAAK,YAAY,GACb;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,OAAO,GAAG,OAAO,GAAG,UAAU,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,KAAK,CAAC;CACtB,GACD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEN,KAAK,gBAAgB,GAAG;IACtB,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,IAAI,CAAC;IACvC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,EAAE,EAAE,WAAW,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAkNlD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@udixio/ui-react",
3
- "version": "2.8.0",
3
+ "version": "2.8.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -43,7 +43,46 @@ export const BlockScroll: React.FC<BlockScrollProps> = ({
43
43
  onScroll?.(payload);
44
44
  };
45
45
 
46
+ const findScrollableParent = (
47
+ node: HTMLElement | null,
48
+ ): HTMLElement | null => {
49
+ let elNode: HTMLElement | null = node;
50
+ while (
51
+ elNode &&
52
+ elNode !== document.body &&
53
+ elNode !== document.documentElement
54
+ ) {
55
+ const style = window.getComputedStyle(elNode);
56
+ const overflowY = style.overflowY || style.overflow;
57
+ const isScrollableY =
58
+ (overflowY === 'auto' || overflowY === 'scroll') &&
59
+ elNode.scrollHeight > elNode.clientHeight;
60
+ if (isScrollableY) return elNode;
61
+ elNode = elNode.parentElement;
62
+ }
63
+ return null;
64
+ };
65
+
46
66
  const onWheel = (e: WheelEvent) => {
67
+ // Auto-detect closest scrollable ancestor and allow native scroll when it can handle the intent
68
+ const target = e.target as HTMLElement | null;
69
+
70
+ const scrollableParent = findScrollableParent(target);
71
+
72
+ if (scrollableParent && scrollableParent !== el) {
73
+ const canScrollDown =
74
+ scrollableParent.scrollTop <
75
+ scrollableParent.scrollHeight - scrollableParent.clientHeight;
76
+ const canScrollUp = scrollableParent.scrollTop > 0;
77
+
78
+ // Wheel: positive deltaY => scroll down, negative => scroll up
79
+ if ((e.deltaY > 0 && canScrollDown) || (e.deltaY < 0 && canScrollUp)) {
80
+ // Let the native scrolling happen inside the scrollable element
81
+ return;
82
+ }
83
+ }
84
+
85
+ // Otherwise, block native scroll and emit intent for global smooth scroll
47
86
  e.preventDefault();
48
87
  emitIntent({
49
88
  type: 'intent',
@@ -64,9 +103,31 @@ export const BlockScroll: React.FC<BlockScrollProps> = ({
64
103
  if (!touch) return;
65
104
  const t = e.touches[0];
66
105
  if (!t || !lastTouch.current) return;
67
- e.preventDefault();
106
+
68
107
  const dx = lastTouch.current.x - t.clientX;
69
108
  const dy = lastTouch.current.y - t.clientY;
109
+
110
+ // Auto-detect closest scrollable ancestor for touch and allow native scroll when possible
111
+ const target = e.target as HTMLElement | null;
112
+
113
+ const scrollableParent = findScrollableParent(target);
114
+
115
+ if (scrollableParent && scrollableParent !== el) {
116
+ const canScrollDown =
117
+ scrollableParent.scrollTop <
118
+ scrollableParent.scrollHeight - scrollableParent.clientHeight;
119
+ const canScrollUp = scrollableParent.scrollTop > 0;
120
+
121
+ // Touch: dy > 0 means user moves finger up -> intent to scroll down
122
+ if ((dy > 0 && canScrollDown) || (dy < 0 && canScrollUp)) {
123
+ // Update last touch and allow native scroll inside the element
124
+ lastTouch.current = { x: t.clientX, y: t.clientY };
125
+ return;
126
+ }
127
+ }
128
+
129
+ // Otherwise block and emit intent for global smooth scroll
130
+ e.preventDefault();
70
131
  lastTouch.current = { x: t.clientX, y: t.clientY };
71
132
  emitIntent({
72
133
  type: 'intent',