From 7bcdcdebde16060b983859f13e2506dcd0d8561f Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Wed, 17 Jan 2018 09:39:17 -0800 Subject: [PATCH] Scroll volume if there are no tracks to scroll --- js/actionCreators.js | 8 ++++++-- js/components/PlaylistWindow/TrackList.js | 9 +-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/js/actionCreators.js b/js/actionCreators.js index 25349f57..606a791d 100644 --- a/js/actionCreators.js +++ b/js/actionCreators.js @@ -468,11 +468,15 @@ export function scrollNTracks(n) { }; } -export function scrollPlaylistByDelta(delta) { +export function scrollPlaylistByDelta(e) { + e.preventDefault(); return (dispatch, getState) => { const state = getState(); + if (getOverflowTrackCount(state)) { + e.stopPropagation(); + } const totalPixelHeight = state.playlist.trackOrder.length * TRACK_HEIGHT; - const percentDelta = delta / totalPixelHeight * 100; + const percentDelta = e.deltaY / totalPixelHeight * 100; dispatch({ type: SET_PLAYLIST_SCROLL_POSITION, position: clamp( diff --git a/js/components/PlaylistWindow/TrackList.js b/js/components/PlaylistWindow/TrackList.js index ec3a47bc..25051058 100644 --- a/js/components/PlaylistWindow/TrackList.js +++ b/js/components/PlaylistWindow/TrackList.js @@ -13,7 +13,6 @@ class TrackList extends React.Component { constructor(props) { super(props); this._handleMoveClick = this._handleMoveClick.bind(this); - this._handleWeel = this._handleWeel.bind(this); } _renderTracks(format) { @@ -29,12 +28,6 @@ class TrackList extends React.Component { )); } - _handleWeel(e) { - this.props.scrollPlaylistByDelta(e.deltaY); - e.preventDefault(); - e.stopPropagation(); - } - _handleMoveClick(e) { if (!this._node) { return; @@ -72,7 +65,7 @@ class TrackList extends React.Component { className="playlist-tracks" style={{ height: "100%" }} onClick={this.props.selectZero} - onWheel={this._handleWeel} + onWheel={this.props.scrollPlaylistByDelta} >
{this._renderTracks((id, i) => `${i + 1 + offset}.`)}