Skip to content

Commit 66372c8

Browse files
committed
Split code for "update clock" and "move the handler".
Those two can be handled separately.
1 parent 192e7dc commit 66372c8

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

player.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,19 +151,16 @@ var player = (function() {
151151
// offsetParent, which is the gutter.
152152
//
153153
_self.dnAudio.addEventListener('timeupdate', function() {
154-
155-
//
156-
// NOTE: This `setInterval` is an attempt to make the seconds to be updated
157-
// really about every one second in the user interface. The main problem
158-
// is that `timeupdate` fires at more random times, which causes our function
159-
// to update the UI at irregular intervals.
160-
//
161-
setInterval(function () {
162-
pos = _self.dnAudio.currentTime / dur * 100;
163-
_self.dnHandler.style.left = pos + '%';
164-
updateClock(_self.dnAudio.currentTime);
165-
}, 1000);
154+
pos = _self.dnAudio.currentTime / dur * 100;
155+
_self.dnHandler.style.left = pos + '%';
166156
});
157+
158+
//
159+
// Updates the clock every 1 second.
160+
//
161+
setInterval(function () {
162+
updateClock(_self.dnAudio.currentTime);
163+
}, 1000);
167164
};
168165

169166
/**
@@ -195,7 +192,8 @@ var player = (function() {
195192
*/
196193
var updateHandler = function updateHandler(evt) {
197194

198-
var lft = evt.pageX + _self.dnGutter;
195+
//var lft = evt.pageX; // + _self.dnGutter;
196+
//l(_self.dnGutter);
199197
var newHandlerPos;
200198

201199
//
@@ -332,6 +330,7 @@ var player = (function() {
332330
};
333331

334332
_self.init = init;
333+
_self.start = playSong;
335334

336335
return _self;
337336
}());

0 commit comments

Comments
 (0)