chore(core): cleanup and replace const with function

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2023-02-07 12:27:41 +01:00
committed by Braks
parent 5abe4ca2e5
commit bb2c4f449a
16 changed files with 183 additions and 164 deletions
+2 -2
View File
@@ -2,7 +2,7 @@ import type { Dimensions, XYPosition } from '~/types'
// returns a number between 0 and 1 that represents the velocity of the movement
// when the mouse is close to the edge of the canvas
const calcAutoPanVelocity = (value: number, min: number, max: number) => {
function calcAutoPanVelocity(value: number, min: number, max: number) {
if (value < min) {
return clamp(Math.abs(value - min), 1, 50) / 50
} else if (value > max) {
@@ -12,7 +12,7 @@ const calcAutoPanVelocity = (value: number, min: number, max: number) => {
return 0
}
export const calcAutoPan = (pos: XYPosition, bounds: Dimensions) => {
export function calcAutoPan(pos: XYPosition, bounds: Dimensions) {
const xMovement = calcAutoPanVelocity(pos.x, 35, bounds.width - 35) * 20
const yMovement = calcAutoPanVelocity(pos.y, 35, bounds.height - 35) * 20