Skip to content

Commit

Permalink
feat(grad): replaced grab tailwind by css class (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
JyTosTT authored Sep 15, 2023
1 parent 7420c50 commit e6cce5f
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion front/src/enums/CursorTypes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export enum CursorTypes {
GRAB = 'cursor-grab'
GRAB = 'canvas-cursor-grab'
}
4 changes: 4 additions & 0 deletions front/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ code {
.board {
background-image: url("./assets/images/canvas.background.png");
background-repeat: repeat;
}

.canvas-cursor-grab {
cursor: grab;
}
4 changes: 2 additions & 2 deletions front/src/services/canvas/Base.canvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ const BaseCanvas: TBaseCanvas = {
this.canvas!.height = height
},

gradCursor (add: boolean = false): void {
add
gradCursor (activate: boolean = false): void {
activate
? this.canvas!.classList.add(CursorTypes.GRAB)
: this.canvas!.classList.remove(CursorTypes.GRAB)
},
Expand Down
2 changes: 1 addition & 1 deletion front/src/services/canvas/MouseEvent.manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const MouseEventManager: TMouseEventManager = {
}
}

this.gradCursor()
this.gradCursor(false)
this.isMoving = false
this.selectedConnector = undefined
this.initialDrawerPosition = undefined
Expand Down
4 changes: 3 additions & 1 deletion front/src/services/canvas/WheelEvent.manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const WheelEventManager: TWheelEventManager = {
finishedInteraction (): void {
this.isInteracting = false
this.interactionTimeout = undefined
this.gradCursor(false)

eventEmitter.emit<EventListenerCallback<TDrawer[]>>(EventEmitters.ON_MOVED_DRAWERS)
},
Expand All @@ -68,11 +69,12 @@ const WheelEventManager: TWheelEventManager = {
},

onMove (event: WheelEvent) {
this.gradCursor(true)

const delta: IPosition = {
x: event.deltaX / this.interactionSensibility,
y: event.deltaY / this.interactionSensibility
}

this.moveDrawersByPosition(delta)
},

Expand Down
2 changes: 1 addition & 1 deletion front/src/types/canvas/Base.canvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ export interface TBaseCanvas {
updateContext: () => void
setCanvasDimensions: (size: ISize) => void
sizeCanvas: () => void
gradCursor: (add?: boolean) => void
gradCursor: (activate?: boolean) => void
boundingClientPosition: (event: MouseEvent | WheelEvent) => IPosition
}

0 comments on commit e6cce5f

Please sign in to comment.