Skip to content

Commit 2af1f0a

Browse files
committed
Release 1.1.1
Also updated dev dependencies.
1 parent 6585e6b commit 2af1f0a

4 files changed

Lines changed: 55 additions & 19 deletions

File tree

CHANGELOG.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Changelog
22

3+
## [1.1.1] - 2026-04-30
4+
### Added
5+
- `enableResize` option: when set to `true`, resize handles are shown on the viewport edges allowing the user to adjust its size ([#9](https://github.com/devtheorem/cropt/issues/9)).
6+
- `CroptState` interface with fields `x`, `y`, `zoom`, `width`, and `height` representing a saved crop state.
7+
- `getState()` method to retrieve the current crop state.
8+
- `bind()` now accepts a `CroptState` object as its second argument to restore zoom, position, and viewport dimensions ([#3](https://github.com/devtheorem/cropt/issues/3), [#10](https://github.com/devtheorem/cropt/issues/10)). Passing a number is still supported for backwards compatibility.
9+
10+
### Changed
11+
- Refreshed demo site to demonstrate the `enableResize` option and saving/restoring crop state.
12+
13+
> [!NOTE]
14+
> Version 1.1.0 was skipped due to a bug with resize handle touchscreen behavior.
15+
16+
317
## [1.0.2] - 2026-01-16
418
### Fixed
519
- Incorrect step value for range input.
@@ -27,12 +41,12 @@ To upgrade code that used the `"circle"` viewport type, instead set the border r
2741

2842
## [0.9.0] - 2024-10-23
2943
### Fixed
30-
- Cropt now clamps image drags to the viewport boundary, rather than ignoring the delta if it would go past the boundary. This fixes unexpected gaps between the image and viewport edges. ([#5]).
44+
- Cropt now clamps image drags to the viewport boundary, rather than ignoring the delta if it would go past the boundary. This fixes unexpected gaps between the image and viewport edges. ([#5](https://github.com/devtheorem/cropt/pull/5)).
3145

3246

3347
## [0.8.9] - 2024-06-26
3448
### Fixed
35-
- Image content is no longer doubled when resizing a large image with transparency ([#1]).
49+
- Image content is no longer doubled when resizing a large image with transparency ([#1](https://github.com/devtheorem/cropt/pull/1)).
3650

3751

3852
## [0.8.8] - 2023-11-21
@@ -85,9 +99,8 @@ This is the initial pre-release after forking from [Foliotek/Croppie](https://gi
8599
- `enableResize` option.
86100
- `showZoomer` option (hide via CSS instead if desired).
87101

88-
[#1]: https://github.com/devtheorem/cropt/pull/1
89-
[#5]: https://github.com/devtheorem/cropt/pull/5
90102
[#6]: https://github.com/devtheorem/cropt/issues/6
103+
[1.1.1]: https://github.com/devtheorem/cropt/compare/v1.0.2...v1.1.1
91104
[1.0.2]: https://github.com/devtheorem/cropt/compare/v1.0.1...v1.0.2
92105
[1.0.1]: https://github.com/devtheorem/cropt/compare/v1.0.0...v1.0.1
93106
[1.0.0]: https://github.com/devtheorem/cropt/compare/v0.9.1...v1.0.0

README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ Default value: `{ width: 220, height: 220, borderRadius: "0px" }`
4343
Defines the size and shape of the crop box.
4444
For a circle shape, set the border radius to `"50%"`.
4545

46+
### `enableResize`
47+
48+
Type: `boolean`
49+
Default value: `false`
50+
51+
If set to `true`, resize handles are shown on the edges of the viewport, allowing the user to adjust its size.
52+
4653
### `zoomerInputClass`
4754

4855
Type: `string`
@@ -52,9 +59,25 @@ Optionally set a different class on the zoom range input to customize styling (e
5259

5360
## Methods
5461

55-
### `bind(src: string, zoom: number | null = null): Promise<void>`
62+
### `bind(src: string, state: number | CroptState | null = null): Promise<void>`
63+
64+
Takes an image URL as the first argument. Returns a `Promise` which resolves when the image has been loaded and state is initialized.
65+
66+
The optional second argument can be:
67+
- A `CroptState` object (returned by `getState()`) to restore a previously saved crop position, zoom, and viewport size.
68+
- A `number` to set only the initial zoom level.
5669

57-
Takes an image URL as the first argument, and an optional initial zoom value. Returns a `Promise` which resolves when the image has been loaded and state is initialized.
70+
### `getState(): CroptState`
71+
72+
Returns the current crop state as a `CroptState` object with fields `x`, `y`, `zoom`, `width`, and `height`. This can be stored and later passed to `bind()` to restore the crop position, zoom level, and viewport size.
73+
74+
```javascript
75+
// Save state when the user is done cropping
76+
const state = cropt.getState();
77+
78+
// Later, restore the same crop position on the same image
79+
cropt.bind("path/to/image.jpg", state);
80+
```
5881

5982
### `destroy(): void`
6083

package-lock.json

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cropt",
3-
"version": "1.0.2",
3+
"version": "1.1.1",
44
"description": "A lightweight JavaScript image cropper",
55
"files": [
66
"src/cropt.*"
@@ -12,10 +12,10 @@
1212
"bootstrap": "^5.3.8",
1313
"gh-pages": "^6.3.0",
1414
"http-server": "^14.1.1",
15-
"prettier": "^3.8.2",
15+
"prettier": "^3.8.3",
1616
"sass": "1.78",
1717
"shx": "^0.4.0",
18-
"typescript": "^6.0.2"
18+
"typescript": "^6.0.3"
1919
},
2020
"scripts": {
2121
"deploy": "gh-pages -d ./demo",

0 commit comments

Comments
 (0)