Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed bug of multiple intervals if play is called repeatedly

  • Loading branch information...
commit df9b57384dc980c0a4c17186053fa58866b293d7 1 parent 5d310b8
@cbaigorri authored
View
1  app/public/js/jquery.simplesprite.js
@@ -33,6 +33,7 @@
this.play = function() {
var $this;
$this = this;
+ if (typeof interval !== 'undefined') clearInterval(interval);
interval = setInterval(function() {
if (settings.direction === 'x') {
$this.css('background-position', ((count * settings.width) * -1) + 'px 0px');
View
4 app/public/js/jquery.simplesprite.min.js
@@ -1,2 +1,2 @@
-(function(){var b;b=jQuery;b.fn.simpleSprite=function(e){var c,d,a;a=b.extend({},b.fn.simpleSprite.defaults,e);c=0;d=this;this.each(function(){a.sprite!==""&&b(this).css({overflow:"hidden","background-image":"url("+a.sprite+")",width:a.width,height:a.height});if(a.autoplay)return this.play()});this.play=function(){var b;b=this;d=setInterval(function(){a.direction==="x"?b.css("background-position",c*a.width*-1+"px 0px"):b.css("background-position","0px "+c*a.height*-1+"px");++c===a.frames&&(a.loop?
-c=0:clearInterval(d));return this},1E3/a.fps);return this};this.stop=function(){typeof d!=="undefined"&&clearInterval(d);return this};return this};b.fn.simpleSprite.defaults={fps:30,frames:10,width:0,height:0,sprite:"",autoplay:!0,loop:!0,direction:"x"}}).call(this);
+(function(){var b;b=jQuery;b.fn.simpleSprite=function(e){var d,c,a;a=b.extend({},b.fn.simpleSprite.defaults,e);d=0;c=this;this.each(function(){a.sprite!==""&&b(this).css({overflow:"hidden","background-image":"url("+a.sprite+")",width:a.width,height:a.height});if(a.autoplay)return this.play()});this.play=function(){var b;b=this;typeof c!=="undefined"&&clearInterval(c);c=setInterval(function(){a.direction==="x"?b.css("background-position",d*a.width*-1+"px 0px"):b.css("background-position","0px "+d*
+a.height*-1+"px");++d===a.frames&&(a.loop?d=0:clearInterval(c));return this},1E3/a.fps);return this};this.stop=function(){typeof c!=="undefined"&&clearInterval(c);return this};return this};b.fn.simpleSprite.defaults={fps:30,frames:10,width:0,height:0,sprite:"",autoplay:!0,loop:!0,direction:"x"}}).call(this);
View
1  app/src/SimpleSprite.coffee
@@ -27,6 +27,7 @@ $.fn.simpleSprite = (options) ->
@play = () ->
$this = this
+ if typeof interval isnt 'undefined' then clearInterval(interval)
interval = setInterval ->
if settings.direction == 'x'
$this.css('background-position', ((count * settings.width) * -1) + 'px 0px' )
Please sign in to comment.
Something went wrong with that request. Please try again.