Skip to content

Commit

Permalink
client: smoother track slider
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrk committed Dec 31, 2014
1 parent d76933f commit 09d2b43
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/client/app.js
Expand Up @@ -1826,6 +1826,8 @@ function getCurrentTrackPosition(){
}

function updateSliderPos() {
window.requestAnimationFrame(updateSliderPos);

if (userIsSeeking) return;

var duration, disabled, elapsed, sliderPos;
Expand Down Expand Up @@ -1883,7 +1885,6 @@ function renderNowPlaying() {
nowPlayingToggleIconDom.classList.remove(oldClass);
nowPlayingToggleIconDom.classList.add(newClass);
trackSliderDom.disabled = (player.isPlaying == null);
updateSliderPos();
renderVolumeSlider();
}

Expand Down Expand Up @@ -2858,7 +2859,7 @@ function setUpNowPlayingUi() {
volSlider.addEventListener('mousedown', onVolSliderMouseDown, false);
volSlider.addEventListener('mouseup', onVolSliderMouseUp, false);

setInterval(updateSliderPos, 100);
updateSliderPos();
}

function onVolSliderMouseDown(ev) {
Expand Down
6 changes: 3 additions & 3 deletions src/public/index.html
Expand Up @@ -17,11 +17,11 @@
</div>
<div id="client-vol" style="display: none">
<span class="icon icon-volume-off"></span>
<input type="range" id="client-vol-slider" min="0.0" max="1.0" step="0.001" tabindex="-1">
<input type="range" id="client-vol-slider" min="0.0" max="1.0" step="0.0001" tabindex="-1">
<span class="icon icon-volume-on"></span>
</div>
<h1 id="track-display"></h1>
<input type="range" id="track-slider" min="0.0" max="1.0" step="0.001" tabindex="-1">
<input type="range" id="track-slider" min="0.0" max="1.0" step="0.0001" tabindex="-1">
<span id="nowplaying-time-elapsed"></span>
<span id="nowplaying-time-left"></span>
<div style="clear: both;"></div>
Expand Down Expand Up @@ -172,7 +172,7 @@ <h1>Sound</h1>
</div>
<div id="vol">
<span class="icon icon-volume-off"></span>
<input type="range" id="vol-slider" min="0.0" max="2.0" step="0.001">
<input type="range" id="vol-slider" min="0.0" max="2.0" step="0.0001">
<span class="icon icon-volume-on"></span>
</div>
<div style="clear: both;"></div>
Expand Down

0 comments on commit 09d2b43

Please sign in to comment.