diff --git a/README.md b/README.md index cdd1d12..eec19ac 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ jQuery Coverflow ================ -Version 1.1.9 +Version 1.1.10 Copyright © 2013-2015 Martijn van der Lee (http://martijn.vanderlee.com). MIT Open Source license applies. @@ -147,31 +147,37 @@ or removing covers or changing the covers yourself. Events ------ ### **change** -Triggered whenever the current cover index changes. +Triggered whenever the current cover index changes. This includes initially and +for each cover passed by when skipping past multiple covers. Change triggers as +soon as the cover is on front; this may be before or after it's animation is +completed (but only once!). -`function(event, cover, index)` +Callback: `function(event, cover, index)` ### **confirm** Triggered when the user clicks on the current cover. -Callback signature: `function(event, cover, index)` +Callback: `function(event, cover, index)` `event.originalEvent.target` contains the DOM element that was clicked to trigger the confirm event. ### **select** -Triggered whenever a cover is selected. This includes initially. -`function(event, cover, index)` +Triggered whenever a cover is selected. This includes initially. In contrast to +the `change` event, `select` only triggers once after the requested cover +position has been reached. + +Callback: `function(event, cover, index)` ### **animateStep** Triggered for every animation frame. Use this event to customize how the animation looks if the default options provide insufficient control. -Callback signature: `function(event, cover, offset, isVisible, isMiddle, sin, cos)` +Callback: `function(event, cover, offset, isVisible, isMiddle, sin, cos)` ### **animateComplete** Triggered after the animation has stopped. A final `animateStep` will be triggered after animation as well, so you don't need to use the `animateComplete` event for normal animation frames. -Callback signature: `function(event, cover, offset, isVisible, isMiddle, sin, cos)` \ No newline at end of file +Callback: `function(event, cover, offset, isVisible, isMiddle, sin, cos)` \ No newline at end of file diff --git a/bower.json b/bower.json index e81381d..282e9c7 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "Vanderlee Coverflow", - "version": "1.1.9", + "version": "1.1.10", "homepage": "https://github.com/vanderlee/coverflow", "authors": [ "Martijn van der Lee " diff --git a/demo.html b/demo.html index 4733358..ba499ad 100644 --- a/demo.html +++ b/demo.html @@ -134,7 +134,7 @@ console.log('Confirm'); }, - select: function(event, cover) { + change: function(event, cover) { var img = $(cover).children().andSelf().filter('img').last(); $('#photos-name').text(img.data('name') || 'unknown'); } diff --git a/jqcoverflow.jquery.json b/jqcoverflow.jquery.json index 29d506e..3c2a610 100644 --- a/jqcoverflow.jquery.json +++ b/jqcoverflow.jquery.json @@ -1,6 +1,6 @@ { "name": "jqcoverflow", - "version": "1.1.9", + "version": "1.1.10", "title": "Vanderlee Coverflow", "description": "A jQuery-based Coverflow components with optional mousewheel, CSS3 interpolation, transformations, touch swipe, reflections and more.", "author": { diff --git a/jquery.coverflow.js b/jquery.coverflow.js index 0bb913c..9edf37c 100644 --- a/jquery.coverflow.js +++ b/jquery.coverflow.js @@ -130,7 +130,7 @@ that.refresh(); }; - that._window_handler_keydown = function(event) { + that._window_handler_keydown = function(event) { if (that.hovering) { switch (event.which) { case 36: // home @@ -211,7 +211,9 @@ index = Math.max(0, Math.min(index, covers.length - 1)); if (index !== that.options.index) { - this.refresh(); // pre-correct for reflection/mods + // Fix reflections + covers.css('position', 'absolute'); + this._frame(that.options.index); if (animate === true || that.options.duration === 0) { that.options.index = Math.round(index); @@ -315,16 +317,16 @@ }); }, - refresh: function(duration, index) { + refresh: function(duration, index) { var that = this, - previous = null, + previous = that.currentIndex, covers = that._getCovers(), - covercount = covers.length; + covercount = covers.length, + triggered = false; covers.css('position', 'absolute'); - that.element.stop().animate({ - '__coverflow_frame': index || that.options.index + '__coverflow_frame': index || that.options.index }, { 'easing': that.options.easing, 'duration': duration || 0, @@ -334,13 +336,17 @@ that.currentIndex = Math.max(0, Math.min(Math.round(now), covercount - 1)); if (previous !== that.currentIndex) { previous = that.currentIndex; - that._callback('change'); - that._callback('select'); - } + that._callback('change'); + if (that.currentIndex === that.options.index) { + triggered = true; + } + } }, - 'complete': function() { - that.currentIndex = that.options.index; - that._callback('change'); + 'complete': function() { + that.currentIndex = that.options.index; + if (!triggered) { + that._callback('change'); + } that._callback('select'); } });