Skip to content

Commit

Permalink
feat(viewer): add mouse leave observable and apply to takeUntil
Browse files Browse the repository at this point in the history
  • Loading branch information
LTakhyunKim committed Jun 9, 2023
1 parent 20c6e86 commit 4b9e361
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useRef } from 'react'
import { fromEvent, tap, switchMap, map, takeUntil, filter, Subscription } from 'rxjs'
import { fromEvent, tap, switchMap, map, takeUntil, filter, Subscription, merge } from 'rxjs'
import { Element, OnViewportChange } from '../../../types'
import { formatCornerstoneViewport } from '../../../utils/cornerstoneHelper/formatViewport'
import {
Expand Down Expand Up @@ -117,6 +117,7 @@ export default function useHandleDrag({ image, element, interaction, onViewportC
const mousedown$ = fromEvent<MouseEvent>(<HTMLDivElement>element, 'mousedown')
const mousemove$ = fromEvent<MouseEvent>(<HTMLDivElement>element, 'mousemove')
const mouseup$ = fromEvent<MouseEvent>(<HTMLDivElement>element, 'mouseup')
const mouseleave$ = fromEvent<MouseEvent>(<HTMLDivElement>element, 'mouseleave')
let dragType: DragType | undefined

subscriptionRef.current = mousedown$
Expand Down Expand Up @@ -155,7 +156,7 @@ export default function useHandleDrag({ image, element, interaction, onViewportC
deltaY,
}
}),
takeUntil(mouseup$)
takeUntil(merge(mouseup$, mouseleave$))
)
})
)
Expand Down

0 comments on commit 4b9e361

Please sign in to comment.