Handle mouseUp event outside of Overview component
This commit is contained in:
parent
4580915c3c
commit
33e6814fce
|
@ -158,8 +158,8 @@ function App(): JSX.Element {
|
||||||
height={80}
|
height={80}
|
||||||
position={position}
|
position={position}
|
||||||
selection={viewport}
|
selection={viewport}
|
||||||
onSelectionStart={(x1: number) => {
|
onSelectionStart={() => {
|
||||||
console.log('onSelectionStart', x1);
|
// empty
|
||||||
}}
|
}}
|
||||||
onSelectionChange={handleOverviewSelectionChange}
|
onSelectionChange={handleOverviewSelectionChange}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -46,6 +46,17 @@ export const Overview: React.FC<Props> = ({
|
||||||
|
|
||||||
// effects
|
// effects
|
||||||
|
|
||||||
|
// handle global mouse up.
|
||||||
|
// Currently this adds and removes the global event listener every time the
|
||||||
|
// component is rerendered (which is often when dragging or redrawing). It
|
||||||
|
// works but probably better to optimize this for performance reasons.
|
||||||
|
useEffect(() => {
|
||||||
|
window.addEventListener('mouseup', handleMouseUp);
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('mouseup', handleMouseUp);
|
||||||
|
};
|
||||||
|
}, [mode, newSelection]);
|
||||||
|
|
||||||
// load peaks on mediaset change
|
// load peaks on mediaset change
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async function () {
|
(async function () {
|
||||||
|
@ -244,7 +255,6 @@ export const Overview: React.FC<Props> = ({
|
||||||
style={hudCanvasStyles}
|
style={hudCanvasStyles}
|
||||||
onMouseDown={handleMouseDown}
|
onMouseDown={handleMouseDown}
|
||||||
onMouseMove={handleMouseMove}
|
onMouseMove={handleMouseMove}
|
||||||
onMouseUp={handleMouseUp}
|
|
||||||
></canvas>
|
></canvas>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|
Loading…
Reference in New Issue