@@ -188,34 +188,34 @@ export const getNewStyle = (type, rect, deltaW, deltaH, ratio, minWidth, minHeig
188
188
}
189
189
}
190
190
191
+ const cursorStartMap = { n : 0 , ne : 1 , e : 2 , se : 3 , s : 4 , sw : 5 , w : 6 , nw : 7 }
192
+ const cursorDirectionArray = [ 'n' , 'ne' , 'e' , 'se' , 's' , 'sw' , 'w' , 'nw' ]
193
+ const cursorMap = { 0 : 0 , 1 : 1 , 2 : 2 , 3 : 2 , 4 : 3 , 5 : 4 , 6 : 4 , 7 : 5 , 8 : 6 , 9 : 6 , 10 : 7 , 11 : 8 }
191
194
export const getCursor = ( rotateAngle , d ) => {
192
- const startMap = { n : 0 , ne : 1 , e : 2 , se : 3 , s : 4 , sw : 5 , w : 6 , nw : 7 }
193
- const directionArray = [ 'n' , 'ne' , 'e' , 'se' , 's' , 'sw' , 'w' , 'nw' ]
194
- const map = { 0 : 0 , 1 : 1 , 2 : 2 , 3 : 2 , 4 : 3 , 5 : 4 , 6 : 4 , 7 : 5 , 8 : 6 , 9 : 6 , 10 : 7 , 11 : 8 }
195
- const increment = map [ Math . floor ( rotateAngle / 30 ) ]
196
- const index = startMap [ d ]
195
+ const increment = cursorMap [ Math . floor ( rotateAngle / 30 ) ]
196
+ const index = cursorStartMap [ d ]
197
197
const newIndex = ( index + increment ) % 8
198
- return directionArray [ newIndex ]
198
+ return cursorDirectionArray [ newIndex ]
199
199
}
200
200
201
- export const centerToTL = ( { centerX, centerY, width, height, rotateAngle } ) => {
202
- const top = centerY - height / 2
203
- const left = centerX - width / 2
204
- return { top, left, width, height, rotateAngle }
205
- }
201
+ export const centerToTL = ( { centerX, centerY, width, height, rotateAngle } ) => ( {
202
+ top : centerY - height / 2 ,
203
+ left : centerX - width / 2 ,
204
+ width,
205
+ height,
206
+ rotateAngle
207
+ } )
206
208
207
- export const tLToCenter = ( { top, left, width, height, rotateAngle } ) => {
208
- return {
209
- position : {
210
- centerX : left + width / 2 ,
211
- centerY : top + height / 2
212
- } ,
213
- size : {
214
- width,
215
- height
216
- } ,
217
- transform : {
218
- rotateAngle
219
- }
209
+ export const tLToCenter = ( { top, left, width, height, rotateAngle } ) => ( {
210
+ position : {
211
+ centerX : left + width / 2 ,
212
+ centerY : top + height / 2
213
+ } ,
214
+ size : {
215
+ width,
216
+ height
217
+ } ,
218
+ transform : {
219
+ rotateAngle
220
220
}
221
- }
221
+ } )
0 commit comments