ResizeTooltip 是一个用于在元素尺寸变化时显示其宽度和高度的组件。它适用于需要实时监控元素尺寸的 WordPress 开发场景,如编辑器或布局工具。
const Example = () => {
return (
<div style={ { position: 'relative' } }>
<ResizeTooltip />
...
</div>
);
};ResizeTooltip displays the dimensions of an element whenever the width or height of the element changes.
const Example = () => {
return (
<div style={ { position: 'relative' } }>
<ResizeTooltip />
...
</div>
);
};
Be sure that the parent element containing <ResizeTooltip /> has the position style property defined. This is important as <ResizeTooltip /> uses position based techniques to determine size changes.
<ResizeTooltip /> has three positions;
bottom (Default)cornerbottomThe bottom position (default) renders the dimensions label at the bottom-center of the (parent) element.
cornerThe corner position renders the dimensions label in the top-right corner of the (parent) element.
Limits the label to render corresponding to the axis. By default, the label will automatically render based on both x and y changes.
Stringx | yDuration (in ms) before the label disappears after resize event.
Number180Determines if the label can render.
BooleantrueCallback Ref for the label element.
FunctionCallback function when the (observed) element resizes, specifically with a mousemove based event.
FunctionCallback function when the (observed) element resizes.
FunctionThe positions for the label.
Stringcornerbottom | cornerRenders a PX unit suffix after the width or height value in the label.
BooleantrueThe z-index style property for the label.
Number1000