@@ -70,11 +70,7 @@ export const handleCanvasMouseDown = ({
7070 canvas . isDrawingMode = false ;
7171
7272 // if target is the selected shape or active selection, set isDrawing to false
73- if (
74- target &&
75- ( target . type === selectedShapeRef . current ||
76- target . type === "activeSelection" )
77- ) {
73+ if ( target && ( target . type === selectedShapeRef . current || target . type === "activeSelection" ) ) {
7874 isDrawing . current = false ;
7975
8076 // set active object to target
@@ -89,10 +85,7 @@ export const handleCanvasMouseDown = ({
8985 isDrawing . current = true ;
9086
9187 // create custom fabric object/shape and set it to shapeRef
92- shapeRef . current = createSpecificShape (
93- selectedShapeRef . current ,
94- pointer as any
95- ) ;
88+ shapeRef . current = createSpecificShape ( selectedShapeRef . current , pointer as any ) ;
9689
9790 // if shapeRef is not null, add it to canvas
9891 if ( shapeRef . current ) {
@@ -215,10 +208,7 @@ export const handleCanvasObjectModified = ({
215208} ;
216209
217210// update shape in storage when path is created when in freeform mode
218- export const handlePathCreated = ( {
219- options,
220- syncShapeInStorage,
221- } : CanvasPathCreated ) => {
211+ export const handlePathCreated = ( { options, syncShapeInStorage } : CanvasPathCreated ) => {
222212 // get path object
223213 const path = options . path ;
224214 if ( ! path ) return ;
@@ -233,11 +223,7 @@ export const handlePathCreated = ({
233223} ;
234224
235225// check how object is moving on canvas and restrict it to canvas boundaries
236- export const handleCanvasObjectMoving = ( {
237- options,
238- } : {
239- options : fabric . IEvent ;
240- } ) => {
226+ export const handleCanvasObjectMoving = ( { options } : { options : fabric . IEvent } ) => {
241227 // get target object which is moving
242228 const target = options . target as fabric . Object ;
243229
@@ -251,21 +237,15 @@ export const handleCanvasObjectMoving = ({
251237 if ( target && target . left ) {
252238 target . left = Math . max (
253239 0 ,
254- Math . min (
255- target . left ,
256- ( canvas . width || 0 ) - ( target . getScaledWidth ( ) || target . width || 0 )
257- )
240+ Math . min ( target . left , ( canvas . width || 0 ) - ( target . getScaledWidth ( ) || target . width || 0 ) )
258241 ) ;
259242 }
260243
261244 // restrict object to canvas boundaries (vertical)
262245 if ( target && target . top ) {
263246 target . top = Math . max (
264247 0 ,
265- Math . min (
266- target . top ,
267- ( canvas . height || 0 ) - ( target . getScaledHeight ( ) || target . height || 0 )
268- )
248+ Math . min ( target . top , ( canvas . height || 0 ) - ( target . getScaledHeight ( ) || target . height || 0 ) )
269249 ) ;
270250 }
271251} ;
@@ -327,19 +307,15 @@ export const handleCanvasObjectScaling = ({
327307 ? selectedElement ?. height ! * selectedElement ?. scaleY
328308 : selectedElement ?. height ;
329309
330- setElementAttributes ( ( prev ) => ( {
310+ setElementAttributes ( prev => ( {
331311 ...prev ,
332312 width : scaledWidth ?. toFixed ( 0 ) . toString ( ) || "" ,
333313 height : scaledHeight ?. toFixed ( 0 ) . toString ( ) || "" ,
334314 } ) ) ;
335315} ;
336316
337317// render canvas objects coming from storage on canvas
338- export const renderCanvas = ( {
339- fabricRef,
340- canvasObjects,
341- activeObjectRef,
342- } : RenderCanvas ) => {
318+ export const renderCanvas = ( { fabricRef, canvasObjects, activeObjectRef } : RenderCanvas ) => {
343319 // clear canvas
344320 fabricRef . current ?. clear ( ) ;
345321
@@ -357,7 +333,7 @@ export const renderCanvas = ({
357333 fabric . util . enlivenObjects (
358334 [ objectData ] ,
359335 ( enlivenedObjects : fabric . Object [ ] ) => {
360- enlivenedObjects . forEach ( ( enlivenedObj ) => {
336+ enlivenedObjects . forEach ( enlivenedObj => {
361337 // if element is active, keep it in active state so that it can be edited further
362338 if ( activeObjectRef . current ?. objectId === objectId ) {
363339 fabricRef . current ?. setActiveObject ( enlivenedObj ) ;
0 commit comments