Scroll volume if there are no tracks to scroll

This commit is contained in:
Jordan Eldredge 2018-01-17 09:39:17 -08:00
parent 3b9fdb30e5
commit 7bcdcdebde
2 changed files with 7 additions and 10 deletions

View file

@ -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(

View file

@ -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}
>
<div className="playlist-track-numbers">
{this._renderTracks((id, i) => `${i + 1 + offset}.`)}