Skip to content

Commit 161e2d3

Browse files
committed
Merge pull request #1 from atsuya/patch-1
make begin and end buttons not to trigger events when it is already at the beginning or end
2 parents 980c716 + 1e2e3de commit 161e2d3

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

jquery.cyclify.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,17 @@
9494
};
9595

9696
Cycler.prototype.begin = function() {
97-
this._set_current_cycle(0);
98-
this.callback_if_necessary();
97+
if (this.elements.current_index !== 0) {
98+
this._set_current_cycle(0);
99+
this.callback_if_necessary();
100+
}
99101
};
100102

101103
Cycler.prototype.end = function() {
102-
this._set_current_cycle(this.elements.max - 1);
103-
this.callback_if_necessary();
104+
if (this.elements.current_index !== (this.elements.max - 1)) {
105+
this._set_current_cycle(this.elements.max - 1);
106+
this.callback_if_necessary();
107+
}
104108
};
105109

106110
return new Cycler(this, options);

0 commit comments

Comments
 (0)