import React, { PropTypes } from 'react' import { connect } from 'react-redux' import { bindActionCreators } from 'redux' import * as mopidyActions from '../services/mopidy/actions' class ProgressSlider extends React.Component{ constructor(props){ super(props); } handleClick(e){ var slider = e.target; if (slider.className != 'slider' ) slider = slider.parentElement; var sliderX = e.clientX - slider.getBoundingClientRect().left; var sliderWidth = slider.getBoundingClientRect().width; var percent = (sliderX / sliderWidth ).toFixed(2); if (this.props.connected && this.props.current_track){ var destination_time = this.props.current_track.duration * percent this.props.mopidyActions.seek(destination_time ) this.setState({ animating: false }) } } render(){ var percent = 0 if (this.props.connected && this.props.current_track){ percent = this.props.time_position / this.props.current_track.duration percent = percent * 100; if (percent > 100 ) percent = 100 } return (