react-h5-audio-player
Advanced tools
Comparing version 0.0.3 to 0.1.0
@@ -231,7 +231,12 @@ 'use strict'; | ||
if (dragX) { | ||
_this2.setState({ dragLeft: dragX - _this2.bar.getBoundingClientRect().left }); | ||
var dragLeft = dragX - _this2.bar.getBoundingClientRect().left; | ||
if (dragLeft < 0) { | ||
dragLeft = 0; | ||
} else if (dragLeft > _this2.bar.offsetWidth) { | ||
dragLeft = _this2.bar.offsetWidth - 1; | ||
} | ||
_this2.setState({ dragLeft: dragLeft }); | ||
_this2.props.onDragMove && _this2.props.onDragMove(e); | ||
} | ||
}); | ||
slider.addEventListener('touchmove', function (e) { | ||
@@ -241,3 +246,2 @@ _this2.setState({ dragLeft: e.touches[0].clientX - _this2.bar.getBoundingClientRect().left }); | ||
}); | ||
slider.addEventListener('dragend', function (e) { | ||
@@ -244,0 +248,0 @@ if (!_this2.audio.src) { |
{ | ||
"name": "react-h5-audio-player", | ||
"version": "0.0.3", | ||
"description": "A react audio player with progress bar. Mobile compatible.", | ||
"version": "0.1.0", | ||
"description": "A React audio player with UI. Mobile compatible.", | ||
"main": "./lib/index.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
@@ -19,3 +19,3 @@ React H5 Audio Player | ||
```javascript | ||
```jsx harmony | ||
import AudioPlayer from 'react-h5-audio-player'; | ||
@@ -28,2 +28,3 @@ | ||
onPlay={(e) => console.log('onPlay')} | ||
// other props here | ||
/> | ||
@@ -85,3 +86,3 @@ ); | ||
```html | ||
```jsx harmony | ||
<ReactAudioPlayer | ||
@@ -88,0 +89,0 @@ ref={c => this.player = c} |
@@ -200,8 +200,13 @@ import React from 'react'; | ||
} | ||
if (dragX) { | ||
this.setState({ dragLeft: dragX - this.bar.getBoundingClientRect().left }); | ||
if (dragX ) { | ||
let dragLeft = dragX - this.bar.getBoundingClientRect().left; | ||
if (dragLeft < 0) { | ||
dragLeft = 0; | ||
} else if (dragLeft > this.bar.offsetWidth) { | ||
dragLeft = this.bar.offsetWidth - 1; | ||
} | ||
this.setState({ dragLeft }); | ||
this.props.onDragMove && this.props.onDragMove(e); | ||
} | ||
}); | ||
slider.addEventListener('touchmove', (e) => { | ||
@@ -211,3 +216,2 @@ this.setState({ dragLeft: e.touches[0].clientX - this.bar.getBoundingClientRect().left }); | ||
}); | ||
slider.addEventListener('dragend', (e) => { | ||
@@ -214,0 +218,0 @@ if (!this.audio.src) { |
28782
739
97