`<pacem-rescale>` is a *behavior* that adds resize handles to any element: split panes, dashboard widgets, crop boxes.
Declare it, attach it through `behaviors`, set the limits.
```html
<pacem-rescale id="resize" handles="right" min-width="160" max-width="480"></pacem-rescale>
<aside behaviors="{{ [#resize] }}">…</aside>
```
## Usage
**Attach it.** One `<pacem-rescale>` serves any number of elements, through their `behaviors`.
`handles` picks the edges (`top`, `right`, `bottom`, `left`, or `all`, the default); corners come with the edges they join.
**Set the limits.** `min-width`, `max-width`, `min-height`, `max-height`, in pixels: a drag beyond them stops at the limit.
`keep-proportions` keeps the width/height ratio (and leaves the corners only).
> Sizes are the element's outer (border-box) sizes, whatever its `box-sizing`: the behavior takes padding and borders
> into account when it writes `width`/`height`, so the limits are the size you see.
**React.** `rescale` fires on every move with the size about to be applied (`detail.targetRect`); `rescalestart` and `rescaleend` frame the gesture.
> `rescale` is cancelable: `preventDefault()` and nothing gets applied, then apply the size your way
> (as a percentage, a grid span, a setting saved for next time).
## Customization
The handles are invisible strips (a quarter of the grid spacing thick) on the edges of a `.pacem-rescalable` element:
only the cursor tells they're there. Each one is a `.pacem-rescale` with its side (`.rescale-right`, `.rescale-bottomright`…),
and the `body` gets `.pacem-rescaling` (plus the side) while one is being dragged.
```css
/* show the corner grip, in the accent color */
.pacem-rescalable > .pacem-rescale.rescale-bottomright { opacity: .5; background-color: var(--pacem-color-accent); }
```
## Examples
### A resizable sidebar The editor's sidebar: right edge only, between 120 and 320 pixels.
### A crop box, 4:3 `keep-proportions`: the corners resize, the ratio stays; `rescaleend` reports the final crop.
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.