mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-22 11:15:23 -04:00
Replace splitter e2e test with unit test
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
8a12755164
commit
3a74ce9267
10 changed files with 449 additions and 97 deletions
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { useEffect } from 'react'
|
||||
|
||||
/**
|
||||
* Registers event listener for pointer movement and pointer release on the window object.
|
||||
*
|
||||
* @param onPointerMovement is triggered if the user moves the pointer over the window
|
||||
* @param onPointerRelease is triggered if the pointer is released (touch end or mouse up)
|
||||
*/
|
||||
export const useBindPointerMovementEventOnWindow = (
|
||||
onPointerMovement: (event: MouseEvent | TouchEvent) => void,
|
||||
onPointerRelease: () => void
|
||||
) => {
|
||||
useEffect(() => {
|
||||
const pointerMovement = onPointerMovement
|
||||
const pointerRelease = onPointerRelease
|
||||
window.addEventListener('touchmove', pointerMovement)
|
||||
window.addEventListener('mousemove', pointerMovement)
|
||||
window.addEventListener('touchcancel', pointerRelease)
|
||||
window.addEventListener('touchend', pointerRelease)
|
||||
window.addEventListener('mouseup', pointerRelease)
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('touchmove', pointerMovement)
|
||||
window.removeEventListener('mousemove', pointerMovement)
|
||||
window.removeEventListener('touchcancel', pointerRelease)
|
||||
window.removeEventListener('touchend', pointerRelease)
|
||||
window.removeEventListener('mouseup', pointerRelease)
|
||||
}
|
||||
}, [onPointerMovement, onPointerRelease])
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue