diff --git a/README.md b/README.md index e710405..154715e 100644 --- a/README.md +++ b/README.md @@ -213,6 +213,12 @@ If no `initialScale` is provided `defaultScale` will be used. `number` default `0.3` | **optional** +#### disableRotation + +Disables rotation of a given sticker. + +`Boolean` default `false` | **optional** + #### onDelete A callback function to be called when the delete button is clicked. diff --git a/package-lock.json b/package-lock.json index 12710db..1b3b051 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@wethegit/preact-stickerbook", - "version": "3.0.1", + "version": "3.0.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@wethegit/preact-stickerbook", - "version": "3.0.1", + "version": "3.0.2", "license": "ISC", "dependencies": { "preact": "^10.13.1", diff --git a/package.json b/package.json index df95c1a..05641fe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@wethegit/preact-stickerbook", - "version": "3.0.1", + "version": "3.0.2", "description": "Easily create collage apps that are accessible by default.", "files": [ "dist/*" diff --git a/src/app.jsx b/src/app.jsx index c780232..cc369e8 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -160,6 +160,7 @@ export function App() { onPosition={onPositionSticker} onScale={onScaleSticker} onRotate={onRotateSticker} + disableRotation={sticker.disableRotation} {...sticker} /> ))} diff --git a/src/lib/sticker.jsx b/src/lib/sticker.jsx index 7847aa0..a5c0031 100644 --- a/src/lib/sticker.jsx +++ b/src/lib/sticker.jsx @@ -24,6 +24,7 @@ export default function Sticker({ initialRotation = null, initialPosition = null, defaultScale = 0.3, + disableRotation = false, // hooks onDelete, onReorder, @@ -203,11 +204,15 @@ export default function Sticker({ setScale((cur) => cur + 0.01 * multiplier) // rotate left - if (key === '<' || key === ',') + if (key === '<' || key === ',') { + if (disableRotation) return setRotation((cur) => cur - 0.01 * multiplier) + } // rotate right - else if (key === '>' || key === '.') + else if (key === '>' || key === '.') { + if (disableRotation) return setRotation((cur) => cur + 0.01 * multiplier) + } // Align top if (key === 'w') setPosition((cur) => new Vec2(cur.x, cur.y - bounds.top)) @@ -264,7 +269,8 @@ export default function Sticker({ let initalradius = Math.min(imageDetails.x, imageDetails.y) // Update the rotation / scale of the sticker - setRotationOffset(mousePosition.angle - ROTATION_BUTTON_OFFSET) + if (!disableRotation) + setRotationOffset(mousePosition.angle - ROTATION_BUTTON_OFFSET) setScale( (mousePosition.length + (radius - radius * controlsScale)) / (initalradius * 0.5)