@rc-component/trigger 1.5.3 → 1.5.5
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/README.md +10 -10
- package/es/hooks/useAlign.js +2 -1
- package/lib/hooks/useAlign.js +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# rc-trigger
|
|
1
|
+
# @rc-component/trigger
|
|
2
2
|
|
|
3
3
|
React Trigger Component
|
|
4
4
|
|
|
5
|
-
[![NPM version][npm-image]][npm-url] [![build status][github-actions-image]][github-actions-url] [![Test coverage][coveralls-image]][coveralls-url] [![
|
|
5
|
+
[![NPM version][npm-image]][npm-url] [![build status][github-actions-image]][github-actions-url] [![Test coverage][coveralls-image]][coveralls-url] [![npm download][download-image]][download-url] [![bundle size][bundlephobia-image]][bundlephobia-url] [![dumi][dumi-image]][dumi-url]
|
|
6
6
|
|
|
7
|
-
[npm-image]: http://img.shields.io/npm/v
|
|
8
|
-
[npm-url]: http://npmjs.org/package
|
|
7
|
+
[npm-image]: http://img.shields.io/npm/v/@rc-component/trigger.svg?style=flat-square
|
|
8
|
+
[npm-url]: http://npmjs.org/package/@rc-component/trigger
|
|
9
9
|
[github-actions-image]: https://github.com/react-component/trigger/workflows/CI/badge.svg
|
|
10
10
|
[github-actions-url]: https://github.com/react-component/trigger/actions
|
|
11
11
|
[circleci-image]: https://img.shields.io/circleci/react-component/trigger/master?style=flat-square
|
|
@@ -16,16 +16,16 @@ React Trigger Component
|
|
|
16
16
|
[david-image]: https://david-dm.org/react-component/trigger/status.svg?style=flat-square
|
|
17
17
|
[david-dev-url]: https://david-dm.org/react-component/trigger?type=dev
|
|
18
18
|
[david-dev-image]: https://david-dm.org/react-component/trigger/dev-status.svg?style=flat-square
|
|
19
|
-
[download-image]: https://img.shields.io/npm/dm
|
|
20
|
-
[download-url]: https://npmjs.org/package
|
|
21
|
-
[bundlephobia-url]: https://bundlephobia.com/result?p
|
|
22
|
-
[bundlephobia-image]: https://badgen.net/bundlephobia/minzip
|
|
19
|
+
[download-image]: https://img.shields.io/npm/dm/@rc-component/trigger.svg?style=flat-square
|
|
20
|
+
[download-url]: https://npmjs.org/package/@rc-component/trigger
|
|
21
|
+
[bundlephobia-url]: https://bundlephobia.com/result?p=@rc-component/trigger
|
|
22
|
+
[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/@rc-component/trigger
|
|
23
23
|
[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square
|
|
24
24
|
[dumi-url]: https://github.com/umijs/dumi
|
|
25
25
|
|
|
26
26
|
## Install
|
|
27
27
|
|
|
28
|
-
[](https://npmjs.org/package/@rc-component/trigger)
|
|
29
29
|
|
|
30
30
|
## Usage
|
|
31
31
|
|
|
@@ -34,7 +34,7 @@ Include the default [styling](https://github.com/react-component/trigger/blob/ma
|
|
|
34
34
|
```js
|
|
35
35
|
import React from 'react';
|
|
36
36
|
import ReactDOM from 'react-dom';
|
|
37
|
-
import Trigger from 'rc-trigger';
|
|
37
|
+
import Trigger from '@rc-component/trigger';
|
|
38
38
|
|
|
39
39
|
ReactDOM.render((
|
|
40
40
|
<Trigger
|
package/es/hooks/useAlign.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import isVisible from "rc-util/es/Dom/isVisible";
|
|
3
4
|
import useEvent from "rc-util/es/hooks/useEvent";
|
|
4
5
|
import useLayoutEffect from "rc-util/es/hooks/useLayoutEffect";
|
|
5
6
|
import * as React from 'react';
|
|
@@ -166,7 +167,7 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
|
|
|
166
167
|
var _scaleY = toNum(Math.round(popupHeight / parseFloat(height) * 1000) / 1000);
|
|
167
168
|
|
|
168
169
|
// No need to align since it's not visible in view
|
|
169
|
-
if (_scaleX === 0 || _scaleY === 0 || target instanceof HTMLElement && !target
|
|
170
|
+
if (_scaleX === 0 || _scaleY === 0 || target instanceof HTMLElement && !isVisible(target)) {
|
|
170
171
|
return;
|
|
171
172
|
}
|
|
172
173
|
|
package/lib/hooks/useAlign.js
CHANGED
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.default = useAlign;
|
|
9
9
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
var _isVisible = _interopRequireDefault(require("rc-util/lib/Dom/isVisible"));
|
|
11
12
|
var _useEvent = _interopRequireDefault(require("rc-util/lib/hooks/useEvent"));
|
|
12
13
|
var _useLayoutEffect = _interopRequireDefault(require("rc-util/lib/hooks/useLayoutEffect"));
|
|
13
14
|
var React = _interopRequireWildcard(require("react"));
|
|
@@ -174,7 +175,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
174
175
|
var _scaleY = toNum(Math.round(popupHeight / parseFloat(height) * 1000) / 1000);
|
|
175
176
|
|
|
176
177
|
// No need to align since it's not visible in view
|
|
177
|
-
if (_scaleX === 0 || _scaleY === 0 || target instanceof HTMLElement && !
|
|
178
|
+
if (_scaleX === 0 || _scaleY === 0 || target instanceof HTMLElement && !(0, _isVisible.default)(target)) {
|
|
178
179
|
return;
|
|
179
180
|
}
|
|
180
181
|
|