Part of the Ant Design ecosystem.
๐ DOM alignment utility for positioning one element against another.
English | ็ฎไฝไธญๆ
| Area | Support |
|---|---|
| Purpose | DOM alignment utility for positioning one element against another. |
| Package | @rc-component/dom-align |
| Release | @rc-component/np / rc-np |
npm install @rc-component/dom-alignimport domAlign from '@rc-component/dom-align';
domAlign(sourceNode, targetNode, {
points: ['tl', 'tr'],
offset: [10, 20],
overflow: { adjustX: true, adjustY: true },
});| Option | Description |
|---|---|
points |
Source and target alignment points. |
offset |
Source node offset. |
targetOffset |
Target node offset. |
overflow |
Auto-adjust behavior when the source overflows viewport. |
useCssRight / useCssBottom / useCssTransform |
Choose CSS positioning strategy. |
npm install
npm start
npm test
npm run lint
npm run tsc
npm run compileThe dumi site runs at http://localhost:8000.
npm run prepublishOnlyThe release flow is handled by @rc-component/np through the rc-np command when the package uses the shared release flow.
| name | type | description |
|---|---|---|
| points | String[2] | move point of source node to align with point of target node, such as ['tr','cc'], align top right point of source node with center point of target node. point can be 't'(top), 'b'(bottom), 'c'(center), 'l'(left), 'r'(right) |
| offset | Number[2] | offset source node by offset[0] in x and offset[1] in y. If offset contains percentage string value, it is relative to sourceNode region. |
| targetOffset | Number[2] | offset target node by offset[0] in x and offset[1] in y. If targetOffset contains percentage string value, it is relative to targetNode region. |
| overflow | Object: `{ adjustX: boolean, adjustY: boolean, alwaysByViewport:boolean }` | if adjustX field is true, then will adjust source node in x direction if source node is invisible. if adjustY field is true, then will adjust source node in y direction if source node is invisible. if alwaysByViewport is true, the it will adjust if node is not inside viewport |
| useCssRight | Boolean | whether use css right instead of left to position |
| useCssBottom | Boolean | whether use css bottom instead of top to position |
| useCssTransform | Boolean | whether use css transform instead of left/top/right/bottom to position if browser supports. Defaults to false. |
@rc-component/dom-align is released under the MIT license.