Skip to content

Commit

Permalink
Don't scroll lines when pinning a track (#103)
Browse files Browse the repository at this point in the history
* Don't scroll lines when pinning a track

* Plan for toggling on and off appropriately
  • Loading branch information
ALevansSamsung authored Apr 5, 2024
1 parent 4ec0ec7 commit e080d86
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion ui/src/frontend/track_panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,24 @@ class TrackShell implements m.ClassComponent<TrackShellAttrs> {
...this.getTrackShellButtons(attrs),
attrs.track.getContextMenu(),
m(TrackButton, {
action: () => {
action: (e) => {
// Scroll timeline by height of toggledPinnedTrack
const toBePinned =
!globals.state.pinnedTracks.includes(attrs.trackState.id);
if (e.currentTarget && e.currentTarget instanceof Element) {
const trackShell = e.currentTarget.closest('.track-shell');
if (trackShell) {
let toScroll = trackShell.clientHeight;
if (!toBePinned) {
toScroll *= -1;
}
const parentScrollPanel = trackShell.closest('.scrolling-panel-container');
if (parentScrollPanel) {
parentScrollPanel.scroll(0,
parentScrollPanel.scrollTop + toScroll);
}
}
}
globals.dispatch(
Actions.toggleTrackPinned({trackId: attrs.trackState.id}));
},
Expand Down

0 comments on commit e080d86

Please sign in to comment.