xxf_react 0.4.7 → 0.4.8
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":"ElementVisibilityHooks.d.ts","sourceRoot":"","sources":["../../../src/layout/visibility/ElementVisibilityHooks.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA8B,SAAS,EAAC,MAAM,OAAO,CAAA;AAE5D
|
|
1
|
+
{"version":3,"file":"ElementVisibilityHooks.d.ts","sourceRoot":"","sources":["../../../src/layout/visibility/ElementVisibilityHooks.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA8B,SAAS,EAAC,MAAM,OAAO,CAAA;AAE5D;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAChC,GAAG,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EAClC,UAAU,GAAE,MAAW,EACvB,QAAQ,GAAE,OAAc,GACzB,OAAO,GAAG,IAAI,CAyHhB"}
|
|
@@ -3,6 +3,7 @@ import { useState, useEffect, useRef } from 'react';
|
|
|
3
3
|
/**
|
|
4
4
|
* 监听元素及其所有祖先的可见性
|
|
5
5
|
* 支持检测 display: none、visibility: hidden、opacity: 0
|
|
6
|
+
* 支持 Radix UI 的 data-state 属性变化(如 Tabs.Content)
|
|
6
7
|
*
|
|
7
8
|
* @param ref - 要监听的元素 ref
|
|
8
9
|
* @param debounceMs - 防抖时间(毫秒),默认 16ms(约一帧)
|
|
@@ -71,7 +72,8 @@ export function useElementVisibility(ref, debounceMs = 16, ancestor = true) {
|
|
|
71
72
|
while (parent) {
|
|
72
73
|
observer.observe(parent, {
|
|
73
74
|
attributes: true,
|
|
74
|
-
|
|
75
|
+
// 监听 style、class、以及 data-state(Radix UI)
|
|
76
|
+
attributeFilter: ['style', 'class', 'data-state'],
|
|
75
77
|
});
|
|
76
78
|
// 如果不检查祖先,只监听当前元素后退出
|
|
77
79
|
if (!ancestor)
|