All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- initialMask prop: Added
initialMask?: stringprop toMaskEditorto pre-load a mask provided as a base64 data URL (e.g., saved fromtoMask()), enabling resuming editing sessions or switching between saved masks.- The mask is applied once per unique value (to avoid redundant re-applications).
- When applied it overwrites the current mask canvas, saves the state in history (so undo/redo works from that base), and notifies
onMaskChangeimmediately.
- Storybook demo: Added a reliable "Pre-load existing mask" story demonstrating save → clear → load workflow (includes a forced reload mechanism so the same mask value can be re-applied).
- Tests: Added tests (Vitest + Testing Library) to validate
initialMaskbehavior and subsequent editing.
- Package version bumped to
1.2.0.
- Improved zoom and pan: Fixed a critical issue where zoom didn't correctly maintain the point under the cursor.
- Coordinate calculation correction: Implemented a new mathematical formula for zoom that correctly accounts for CSS transformation.
- Keyboard zoom: Fixed zoom behavior via keyboard shortcuts to follow the current mouse position.
- Zoom behavior: Eliminated axis inversion when zooming at different positions of the image.
- Transformation consistency: Unified logic for all zoom operations (wheel, buttons, shortcuts) to ensure coherent behavior.
- Performance: Optimized transformation calculations to reduce re-renders.
- Code structure: Refactored the
zoomToPointfunction for better readability and maintainability.
The main technical change has been correcting the transformation calculation applied during zoom. The new implementation:
- Correctly calculates the image point under the cursor before zooming
- Applies an improved mathematical formula that considers the order of CSS transformations:
transform: translate(-50%, -50%) scale(effectiveScale) translate(translateX, translateY);
- Uses the correct sign for translation values, considering that CSS
translatemoves the element in the specified direction, but to keep a point under the cursor requires the opposite movement
See commit history for more details about previous changes.