Responsive Snapcast; Customisable scrollWheel attribute, fixes #272
This commit is contained in:
@ -49,23 +49,25 @@ export default class LatencyControl extends React.Component{
|
||||
}
|
||||
|
||||
handleWheel(e){
|
||||
if (this.props.scrollWheel){
|
||||
|
||||
// Identify which direction we've scrolled (inverted)
|
||||
// This is simplified and doesn't consider momentum as it varies wildly
|
||||
// between browsers and devices
|
||||
var direction = (e.deltaY > 0 ? -1 : 1)
|
||||
var value = this.props.value;
|
||||
// Identify which direction we've scrolled (inverted)
|
||||
// This is simplified and doesn't consider momentum as it varies wildly
|
||||
// between browsers and devices
|
||||
var direction = (e.deltaY > 0 ? -1 : 1)
|
||||
var value = this.props.value;
|
||||
|
||||
value += direction * 5
|
||||
value += direction * 5
|
||||
|
||||
if (value > this.props.max){
|
||||
value = this.props.max;
|
||||
} else if (value < -this.props.max){
|
||||
value = -this.props.max;
|
||||
if (value > this.props.max){
|
||||
value = this.props.max;
|
||||
} else if (value < -this.props.max){
|
||||
value = -this.props.max;
|
||||
}
|
||||
|
||||
this.props.onChange(value);
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
this.props.onChange(value);
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
render(){
|
||||
|
||||
@ -118,6 +118,7 @@ class PlaybackControls extends React.Component{
|
||||
|
||||
<section className="volume">
|
||||
<VolumeControl
|
||||
scrollWheel
|
||||
volume={this.props.volume}
|
||||
mute={this.props.mute}
|
||||
onVolumeChange={percent => this.props.mopidyActions.setVolume(percent)}
|
||||
|
||||
@ -26,23 +26,25 @@ export default class VolumeControl extends React.Component{
|
||||
}
|
||||
|
||||
handleWheel(e){
|
||||
if (this.props.scrollWheel){
|
||||
|
||||
// Identify which direction we've scrolled (inverted)
|
||||
// This is simplified and doesn't consider momentum as it varies wildly
|
||||
// between browsers and devices
|
||||
var direction = (e.deltaY > 0 ? -1 : 1)
|
||||
var percent = this.props.volume;
|
||||
|
||||
// Identify which direction we've scrolled (inverted)
|
||||
// This is simplified and doesn't consider momentum as it varies wildly
|
||||
// between browsers and devices
|
||||
var direction = (e.deltaY > 0 ? -1 : 1)
|
||||
var percent = this.props.volume;
|
||||
percent += direction * 5
|
||||
|
||||
percent += direction * 5
|
||||
if (percent > 100){
|
||||
percent = 100
|
||||
} else if (percent < 0){
|
||||
percent = 0
|
||||
}
|
||||
|
||||
if (percent > 100){
|
||||
percent = 100
|
||||
} else if (percent < 0){
|
||||
percent = 0
|
||||
this.props.onVolumeChange(percent);
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
this.props.onVolumeChange(percent);
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
renderMuteButton(){
|
||||
|
||||
Reference in New Issue
Block a user