From a6d27ae3209da846f9fb6aa7166979e05780b1bf Mon Sep 17 00:00:00 2001 From: lonkaars Date: Fri, 21 May 2021 22:13:24 +0200 Subject: timeline cursor jump working now :tada: --- pages/editor.tsx | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'pages/editor.tsx') diff --git a/pages/editor.tsx b/pages/editor.tsx index f37e561..838da2c 100644 --- a/pages/editor.tsx +++ b/pages/editor.tsx @@ -1,6 +1,6 @@ import { CSSProperties, ReactNode, useEffect, useRef, useState } from 'react'; import { animated, useSpring } from 'react-spring'; -import { useGesture } from 'react-use-gesture'; +import { useDrag } from 'react-use-gesture'; import create from 'zustand'; import { loopSlide } from '../timeline'; import { TimedVideoPlayer } from './present'; @@ -161,20 +161,16 @@ function TimelineEditor(props: { }), ); - useGesture( - { - onDrag: ({ offset: [x, _y] }) => { - var frame = Math.max(0, Math.round(getFrameAtOffset(x, timelineZoom)) - 1); - setFrame(frame); - return scrubberSpring.start({ frame }); - }, - }, - { domTarget: scrubberDragRef, eventOptions: { passive: false } }, - ); + useDrag(({ xy: [x, _y] }) => { + var frame = Math.max(0, Math.round(getFrameAtOffset(x - 240, timelineZoom)) - 1); + setFrame(frame); + return scrubberSpring.start({ frame }); + }, { domTarget: scrubberDragRef, eventOptions: { passive: false } }); return <> -
{timelineLabels}
+
+