From 91e3ccd4c706ee59727e1356656e6bdc57685606 Mon Sep 17 00:00:00 2001 From: kinging123 Date: Thu, 6 Nov 2014 09:25:52 +0200 Subject: [PATCH] Pulsing Syntax Improvement Instead of sheduling a removal of the class just before the pulse, you can simply write those two functions one after another. The addClass function will only be called after the removeClass function. I haven't tested it, so I might be wrong, but I think the time it takes for the removeClass function to remove the class is so tiny that you won't see any delays in the scaling of the player. Great video by the way, keep on hacking! --- assets/js/functions.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/assets/js/functions.js b/assets/js/functions.js index f349f24..d5ae037 100755 --- a/assets/js/functions.js +++ b/assets/js/functions.js @@ -4,7 +4,7 @@ $( document ).ready(function() { var $this = $(this), audio = $this.siblings('audio')[0], - bpm = Number($this.siblings('audio').data('bpm')) + bpm = Number($this.siblings('audio').data('bpm')), pulse = (60/bpm)*1000; @@ -26,15 +26,11 @@ $( document ).ready(function() { function pulsing() { - $this.addClass('pulse'); - - setTimeout(function() { - $this.removeClass('pulse'); - }, pulse-100); + $this.removeClass('pulse').addClass('pulse'); } }); -}); \ No newline at end of file +});