Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Click and Drag Timeline Scroll #32

Open
parabuzzle opened this issue May 22, 2023 · 2 comments
Open

Click and Drag Timeline Scroll #32

parabuzzle opened this issue May 22, 2023 · 2 comments

Comments

@parabuzzle
Copy link

I'm trying to figure out a way of clicking and dragging the timeline left and right. It would be great if there was a callback prop for the timeline view similar to onClickTimeArea or onCursorDrag for the entire timeline.

@parabuzzle
Copy link
Author

for now I've made the scroll bar more visible by increasing the size with this css:

.timeline-editor :hover::-webkit-scrollbar:horizontal {
  height: 20px !important;
}

.timeline-editor :hover::-webkit-scrollbar-thumb:horizontal {
  background: #333 !important;
  border-radius: 5px !important;
}

It would still be nice to have the click and drag feature. I noticed on a laptop with 2-finger scroll it works.. but a desktop with no horizontal scroll mouse features, the timeline can be a bit of a pain to work with.

@marcoburrometo
Copy link

I just did something like this in a POC test that I'm doing :)

        <div className="container"
           onMouseDown={() => {
                  draggingRef.current = true;
                  videoRef.current.getInternalPlayer().pause();
              }}
              onMouseUp={() => {
                  draggingRef.current = false;
                  videoRef.current.getInternalPlayer().play();
              }}
              onMouseLeave={() => {
                  draggingRef.current = false;
              }}
              onMouseMove={(e) => {
                  if (draggingRef.current) {
                      const newTime = timelineState.current.getTime() + e.movementX / (SCALEWIDTH / SCALE);
                      const left = newTime * (SCALEWIDTH / SCALE) - timelineState.current.target.clientWidth / 2;

                      console.log('......mouse drag????', newTime, e.movementX);

                      timelineState.current.setTime(newTime);
                      timelineState.current.setScrollLeft(left);
                      videoRef.current.seekTo(newTime);
                      setCurrentTime(newTime);
                      // setCurrentTime(currentTime + direction);
                  }
              }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants