Skip to content

Commit

Permalink
Cleaner code
Browse files Browse the repository at this point in the history
  • Loading branch information
rohanrhu committed Sep 5, 2024
1 parent cbe86e3 commit e2a13b9
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions src/components/Window/Window.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,45 +214,43 @@ function Window({
setScale(1)
setStagingXCompenstation(0)
setStagingYCompenstation(0)
} else {
if (stagedSize[0] && !stagedSize[1]) {
const scale_to_staged = (size[1] > size[0]) ? stagedSize[0] / size[1]: stagedSize[0] / size[0]
} else if (stagedSize[0] && !stagedSize[1]) {
const scale_to_staged = (size[1] > size[0]) ? stagedSize[0] / size[1]: stagedSize[0] / size[0]
const x_compensation = pointer[0] - position[0]
const y_compensation = pointer[1] - position[1]

setRotation(90 * (1 - distance / scaled_distance))
setScale(scale_to_staged)
setStagingXCompenstation(x_compensation)
setStagingYCompenstation(y_compensation)
} else if (!stagedSize[0] && stagedSize[1]) {
const scale_to_staged = (size[0] > size[1]) ? stagedsWidth / size[0]: stagedSize[1] / size[1]
const x_compensation = pointer[0] - position[0]
const y_compensation = pointer[1] - position[1]

setRotation(90 * (1 - distance / scaled_distance))
setScale(scale_to_staged)
setStagingXCompenstation(x_compensation)
setStagingYCompenstation(y_compensation)
} else if (stagedSize[0] && stagedSize[1]) {
if (size[0] > size[1]) {
const scale_to_staged = stagedSize[0] / size[0]
const x_compensation = pointer[0] - position[0]
const y_compensation = pointer[1] - position[1]

setRotation(90 * (1 - distance / scaled_distance))
setScale(scale_to_staged)
setStagingXCompenstation(x_compensation)
setStagingYCompenstation(y_compensation)
} else if (!stagedSize[0] && stagedSize[1]) {
const scale_to_staged = (size[0] > size[1]) ? stagedsWidth / size[0]: stagedSize[1] / size[1]
} else {
const scale_to_staged = stagedSize[1] / size[1]
const x_compensation = pointer[0] - position[0]
const y_compensation = pointer[1] - position[1]

setRotation(90 * (1 - distance / scaled_distance))
setScale(scale_to_staged)
setStagingXCompenstation(x_compensation)
setStagingYCompenstation(y_compensation)
} else if (stagedSize[0] && stagedSize[1]) {
if (size[0] > size[1]) {
const scale_to_staged = stagedSize[0] / size[0]
const x_compensation = pointer[0] - position[0]
const y_compensation = pointer[1] - position[1]

setRotation(90 * (1 - distance / scaled_distance))
setScale(scale_to_staged)
setStagingXCompenstation(x_compensation)
setStagingYCompenstation(y_compensation)
} else {
const scale_to_staged = stagedSize[1] / size[1]
const x_compensation = pointer[0] - position[0]
const y_compensation = pointer[1] - position[1]

setRotation(90 * (1 - distance / scaled_distance))
setScale(scale_to_staged)
setStagingXCompenstation(x_compensation)
setStagingYCompenstation(y_compensation)
}
}
}
}, [pointer, moving, stagingDistance, position, size, stagedSize, scaleX, stagedsWidth])
Expand Down

0 comments on commit e2a13b9

Please sign in to comment.