Skip to content

Commit

Permalink
refactored to be slightly more DRY
Browse files Browse the repository at this point in the history
  • Loading branch information
SlicedSilver committed Jun 29, 2023
1 parent efdd876 commit 1eab8a7
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/gui/pane-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export class PaneWidget implements IDestroyable, MouseEventHandlers {
if (this._state === null) {
return;
}
this._fireDblClickedDelegate(event);
this._fireMouseClickDelegate(this._dblClicked, event);
}

public doubleTapEvent(event: MouseEventHandlerTouchEvent): void {
Expand Down Expand Up @@ -517,18 +517,14 @@ export class PaneWidget implements IDestroyable, MouseEventHandlers {
}

private _fireClickedDelegate(event: MouseEventHandlerEventBase): void {
const x = event.localX;
const y = event.localY;
if (this._clicked.hasListeners()) {
this._clicked.fire(this._model().timeScale().coordinateToIndex(x), { x, y }, event);
}
this._fireMouseClickDelegate(this._clicked, event);
}

private _fireDblClickedDelegate(event: MouseEventHandlerEventBase): void {
private _fireMouseClickDelegate(delegate: Delegate<TimePointIndex | null, Point, TouchMouseEventData>, event: MouseEventHandlerEventBase): void {
const x = event.localX;
const y = event.localY;
if (this._dblClicked.hasListeners()) {
this._dblClicked.fire(this._model().timeScale().coordinateToIndex(x), { x, y }, event);
if (delegate.hasListeners()) {
delegate.fire(this._model().timeScale().coordinateToIndex(x), { x, y }, event);
}
}

Expand Down

0 comments on commit 1eab8a7

Please sign in to comment.