Skip to content

Commit

Permalink
Arrow keys now jump percentage of timeline length (at current zoom le…
Browse files Browse the repository at this point in the history
…vel) #254
  • Loading branch information
mifi committed Feb 24, 2020
1 parent 6bf6856 commit 74585af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/HelpSheet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const HelpSheet = memo(({
<div><kbd>SPACE</kbd>, <kbd>k</kbd> Play/pause</div>
<div><kbd>J</kbd> Slow down video</div>
<div><kbd>L</kbd> Speed up video</div>
<div><kbd></kbd> Seek backward 1 sec</div>
<div><kbd></kbd> Seek forward 1 sec</div>
<div><kbd></kbd> Seek backward 5% of timeline</div>
<div><kbd></kbd> Seek forward 5% of timeline</div>
<div><kbd>,</kbd> Seek backward 1 frame</div>
<div><kbd>.</kbd> Seek forward 1 frame</div>
<div><kbd>I</kbd> Mark in / cut start point</div>
Expand Down
10 changes: 7 additions & 3 deletions src/renderer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ const App = memo(() => {
seekAbs(videoRef.current.currentTime + val);
}, [seekAbs]);

const seekRelPercent = useCallback((val) => {
seekRel(val * (duration / zoom));
}, [seekRel, duration, zoom]);

const shortStep = useCallback((dir) => {
seekRel((1 / (detectedFps || 60)) * dir);
}, [seekRel, detectedFps]);
Expand Down Expand Up @@ -945,8 +949,8 @@ const App = memo(() => {
Mousetrap.bind('k', () => playCommand());
Mousetrap.bind('j', () => changePlaybackRate(-1));
Mousetrap.bind('l', () => changePlaybackRate(1));
Mousetrap.bind('left', () => seekRel(-1));
Mousetrap.bind('right', () => seekRel(1));
Mousetrap.bind('left', () => seekRelPercent(-0.05));
Mousetrap.bind('right', () => seekRelPercent(0.05));
Mousetrap.bind('up', () => jumpSeg(-1));
Mousetrap.bind('down', () => jumpSeg(1));
Mousetrap.bind('.', () => shortStep(1));
Expand Down Expand Up @@ -982,7 +986,7 @@ const App = memo(() => {
};
}, [
addCutSegment, capture, changePlaybackRate, cutClick, playCommand, removeCutSegment,
setCutEnd, setCutStart, seekRel, shortStep, deleteSource, jumpSeg,
setCutEnd, setCutStart, seekRelPercent, shortStep, deleteSource, jumpSeg,
]);

useEffect(() => {
Expand Down

0 comments on commit 74585af

Please sign in to comment.