🍿 Features
- MagicTray and MagicDrawer support snap point ranges. Pass
{ min, max }in place of a snap point, and the side or drawer can rest anywhere between the two. A release outside the range snaps to the closest point, withminandmaxcounting as points. A flick inside a range still carries on to the next point, unless the range setsmomentum: false. - Values inside a range are rounded, to four decimals if both ends are decimals and to whole pixels otherwise.
activeSnapPointand the snap events report the rounded value, andwillSnapTofires once when the target enters a range. - In MagicDrawer, a range that reaches
0closes the drawer when it’s let go withinthreshold.distanceof0. A mouse can’t follow the drawer past the edge of the window, so it would otherwise never reach the closed end. useMagicDrawernow returnsactiveSnapPoint.
❗️ Bug Fixes
- MagicTray’s
threshold.momentumworks again. The distance check overwrote it on every move, so flicks never registered. With the default of1, a fast drag now snaps to the next point. snapToand initial snap points in MagicTray and MagicDrawer ignore a value that is neither a snap point nor inside a range, and log a warning. Before, the tray or drawer jumped to whichever point was closest and reported the value it was given. A snap point written in another unit still works, andactiveSnapPointreports it as configured.- In MagicDrawer, dragging back within
threshold.distancenow returns the drawer to where it started, as in MagicTray. Before, a drag that had passed the threshold once kept its target. - MagicDrawer resolves snap points from its current size, so snapping right after a window resize no longer uses an outdated lookup.
📖 Docs
- MagicTray and MagicDrawer have range demos, and the MagicDrawer page documents
useMagicDrawer. - The MagicTray demos fit narrow screens.
Full Changelog: v1.0.1...v1.1.0