From 681320551a0aa76c90304728229200b5f932a1ec Mon Sep 17 00:00:00 2001 From: Christian Riedel Date: Sat, 13 Oct 2012 12:20:14 +0200 Subject: [PATCH] added 'rotate' event that is triggered when the img src attribute is changed example: $('#images img').on('rotate', {}, function (event, index) { console.log('showing index ' + index); }); --- jquery.threesixty.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/jquery.threesixty.js b/jquery.threesixty.js index 7774e7c..1c9e447 100644 --- a/jquery.threesixty.js +++ b/jquery.threesixty.js @@ -140,7 +140,8 @@ jQuery.fn.threesixty = function(options){ if (newIndex == pic.data("currentIndex")) return; pic.attr("src",imgArr[newIndex]); - pic.data("tempIndex",newIndex); + pic.data("tempIndex",newIndex); + pic.trigger('rotate', newIndex); } else { //The image needs to be moved in its viewport.. moveInViewport(e); @@ -164,9 +165,15 @@ jQuery.fn.threesixty = function(options){ } if (options.method == "auto") { - var speed = options.autoscrollspeed; - var newIndex=0; - window.setInterval(function() { pic.attr("src", imgArr[++newIndex % imgArr.length])} , speed); + var speed = options.autoscrollspeed, + newIndex = 0; + window.setInterval(function () { + + var indexRemainder = ++newIndex % imgArr.length; + + pic.attr("src", imgArr[indexRemainder]); + pic.trigger('rotate', indexRemainder); + } , speed); } }); };