@sheinx/hooks 3.5.8-beta.14 → 3.5.8-beta.16
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.
- package/cjs/common/use-position-style/index.d.ts +1 -0
- package/cjs/common/use-position-style/index.d.ts.map +1 -1
- package/cjs/common/use-position-style/index.js +7 -3
- package/esm/common/use-position-style/index.d.ts +1 -0
- package/esm/common/use-position-style/index.d.ts.map +1 -1
- package/esm/common/use-position-style/index.js +7 -3
- package/package.json +1 -1
@@ -15,6 +15,7 @@ export interface PositionStyleConfig {
|
|
15
15
|
fixedWidth?: boolean | 'min';
|
16
16
|
updateKey?: number | string;
|
17
17
|
adjust?: boolean;
|
18
|
+
offset?: [number, number];
|
18
19
|
}
|
19
20
|
export declare const usePositionStyle: (config: PositionStyleConfig) => {
|
20
21
|
style: React.CSSProperties;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AASnD,MAAM,MAAM,kBAAkB,GAC1B,aAAa,GACb,UAAU,GACV,cAAc,GACd,WAAW,GACX,MAAM,GACN,OAAO,CAAC;AACZ,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,cAAc,GACd,UAAU,GACV,WAAW,GACX,KAAK,GACL,QAAQ,CAAC;AAYb,KAAK,YAAY,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,OAAO,CAAC;AACpE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,YAAY,GAAG,SAAS,CAAC;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IAEd,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAE1C,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAEzC,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,W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,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3B;AAOD,eAAO,MAAM,gBAAgB,WAAY,mBAAmB;;;CAiT3D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
@@ -44,7 +44,8 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
44
44
|
popupElRef = _ref.popupElRef,
|
45
45
|
scrollElRef = _ref.scrollElRef,
|
46
46
|
updateKey = _ref.updateKey,
|
47
|
-
adjust = _ref.adjust
|
47
|
+
adjust = _ref.adjust,
|
48
|
+
offset = _ref.offset;
|
48
49
|
// 初次渲染无样式的时候, 隐藏展示
|
49
50
|
var _useState = (0, _react.useState)(hideStyle),
|
50
51
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -154,6 +155,9 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
154
155
|
};
|
155
156
|
context.containerRect = containerRect;
|
156
157
|
context.containerScroll = containerScroll;
|
158
|
+
console.log('======================');
|
159
|
+
console.log('targetPosition: >>', targetPosition);
|
160
|
+
console.log('======================');
|
157
161
|
if (verticalPosition.includes(targetPosition)) {
|
158
162
|
var _targetPosition$split = targetPosition.split('-'),
|
159
163
|
_targetPosition$split2 = _slicedToArray(_targetPosition$split, 2),
|
@@ -229,11 +233,11 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
229
233
|
_h = _targetPosition$split4[0],
|
230
234
|
_v = _targetPosition$split4[1];
|
231
235
|
if (_v === 'top') {
|
232
|
-
style.top = rect.top - containerRect.top + containerScroll.top;
|
236
|
+
style.top = rect.top - containerRect.top + containerScroll.top - (offset ? offset[1] : 0);
|
233
237
|
style.transform = '';
|
234
238
|
arrayStyle.top = "8px";
|
235
239
|
} else if (_v === 'bottom') {
|
236
|
-
style.top = rect.bottom - containerRect.top + containerScroll.top;
|
240
|
+
style.top = rect.bottom - containerRect.top + containerScroll.top + (offset ? offset[1] : 0);
|
237
241
|
arrayStyle.bottom = "8px";
|
238
242
|
style.transform = 'translateY(-100%)';
|
239
243
|
} else {
|
@@ -15,6 +15,7 @@ export interface PositionStyleConfig {
|
|
15
15
|
fixedWidth?: boolean | 'min';
|
16
16
|
updateKey?: number | string;
|
17
17
|
adjust?: boolean;
|
18
|
+
offset?: [number, number];
|
18
19
|
}
|
19
20
|
export declare const usePositionStyle: (config: PositionStyleConfig) => {
|
20
21
|
style: React.CSSProperties;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AASnD,MAAM,MAAM,kBAAkB,GAC1B,aAAa,GACb,UAAU,GACV,cAAc,GACd,WAAW,GACX,MAAM,GACN,OAAO,CAAC;AACZ,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,cAAc,GACd,UAAU,GACV,WAAW,GACX,KAAK,GACL,QAAQ,CAAC;AAYb,KAAK,YAAY,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,OAAO,CAAC;AACpE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,YAAY,GAAG,SAAS,CAAC;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IAEd,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAE1C,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAEzC,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAC3C,YAAY,EAAE,MAAM,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AASnD,MAAM,MAAM,kBAAkB,GAC1B,aAAa,GACb,UAAU,GACV,cAAc,GACd,WAAW,GACX,MAAM,GACN,OAAO,CAAC;AACZ,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,cAAc,GACd,UAAU,GACV,WAAW,GACX,KAAK,GACL,QAAQ,CAAC;AAYb,KAAK,YAAY,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,OAAO,CAAC;AACpE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,YAAY,GAAG,SAAS,CAAC;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IAEd,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAE1C,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAEzC,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAC3C,YAAY,EAAE,MAAM,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3B;AAOD,eAAO,MAAM,gBAAgB,WAAY,mBAAmB;;;CAiT3D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
@@ -35,7 +35,8 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
35
35
|
popupElRef = _ref.popupElRef,
|
36
36
|
scrollElRef = _ref.scrollElRef,
|
37
37
|
updateKey = _ref.updateKey,
|
38
|
-
adjust = _ref.adjust
|
38
|
+
adjust = _ref.adjust,
|
39
|
+
offset = _ref.offset;
|
39
40
|
// 初次渲染无样式的时候, 隐藏展示
|
40
41
|
var _useState = useState(hideStyle),
|
41
42
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -145,6 +146,9 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
145
146
|
};
|
146
147
|
context.containerRect = containerRect;
|
147
148
|
context.containerScroll = containerScroll;
|
149
|
+
console.log('======================');
|
150
|
+
console.log('targetPosition: >>', targetPosition);
|
151
|
+
console.log('======================');
|
148
152
|
if (verticalPosition.includes(targetPosition)) {
|
149
153
|
var _targetPosition$split = targetPosition.split('-'),
|
150
154
|
_targetPosition$split2 = _slicedToArray(_targetPosition$split, 2),
|
@@ -220,11 +224,11 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
220
224
|
_h = _targetPosition$split4[0],
|
221
225
|
_v = _targetPosition$split4[1];
|
222
226
|
if (_v === 'top') {
|
223
|
-
style.top = rect.top - containerRect.top + containerScroll.top;
|
227
|
+
style.top = rect.top - containerRect.top + containerScroll.top - (offset ? offset[1] : 0);
|
224
228
|
style.transform = '';
|
225
229
|
arrayStyle.top = "8px";
|
226
230
|
} else if (_v === 'bottom') {
|
227
|
-
style.top = rect.bottom - containerRect.top + containerScroll.top;
|
231
|
+
style.top = rect.bottom - containerRect.top + containerScroll.top + (offset ? offset[1] : 0);
|
228
232
|
arrayStyle.bottom = "8px";
|
229
233
|
style.transform = 'translateY(-100%)';
|
230
234
|
} else {
|