Skip to content

Commit 1db5a52

Browse files
Michael DobekidisMichael Dobekidis
Michael Dobekidis
authored and
Michael Dobekidis
committed
fixes #2
1 parent 15c748f commit 1db5a52

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ slider.createSlider({
5252
<li><strong>modal</strong> Add a black modal behind the slider (default false)</li>
5353
<li><strong>modalAlpha</strong> The amount of alpha (opacity) for the slider modal (default 0.7)</li>
5454
<li><strong>staticElements</strong> The static elements that need to be added but not move (default [])</li>
55+
<li><strong>onPrePrevCallback</strong> The function to call `before` the slider moves to the `previous` slide (default false)</li>
56+
<li><strong>onPreNextCallback</strong> The function to call `before` the slider moves to the `next` slide (default false)</li>
57+
<li><strong>onAfterPrevCallback</strong> The function to call `after` the slider moves to the `previous` slide (default false)</li>
58+
<li><strong>onAfterNextCallback</strong> The function to call `after` the slider moves to the `next` slide (default false)</li>
5559
</ul>
5660

5761
<strong>API Functions</strong>

phase-slide.js

+16-6
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,10 @@ phaseSlider = function(game) {
292292
_customHandleNext: options.customHandleNext || "",
293293
_customHandlePrev: options.customHandlePrev || "",
294294
_showHandles: options.showHandles == undefined ? true : options.showHandles,
295-
_onNextCallback: options.onNextCallback || false,
296-
_onPrevCallback: options.onPrevCallback || false,
295+
_onPreNextCallback: options.onPreNextCallback || false,
296+
_onPrePrevCallback: options.onPrePrevCallback || false,
297+
_onAfterNextCallback: options.onAfterNextCallback || false,
298+
_onAfterPrevCallback: options.onAfterPreCallback || false,
297299
_addModal: options.modal || false,
298300
_modalAlpha: options.modalAlpha || 0.7,
299301
_staticElements: options.staticElements || []
@@ -402,14 +404,18 @@ phaseSlider = function(game) {
402404
chevronRight.y = (_this.options._height / 2) - chevronRight.height / 2;
403405
chevronRight.inputEnabled = true;
404406
chevronRight.events.onInputDown.add(function(e, pointer) {
405-
if (_this.options._onNextCallback) {
406-
_this.options._onNextCallback();
407+
if (_this.options._onPreNextCallback) {
408+
_this.options._onPreNextCallback();
407409
}
408410

409411
if (_this.tweenObj.isRunning !== true) {
410412
_this.stopSlider();
411413
_this.goToNext();
412414
}
415+
416+
if (_this.options._onAfterNextCallback) {
417+
_this.options._onAfterNextCallback();
418+
}
413419

414420
}, _this);
415421

@@ -424,14 +430,18 @@ phaseSlider = function(game) {
424430
chevronLeft.y = (_this.options._height / 2) - chevronLeft.height / 2;
425431
chevronLeft.inputEnabled = true;
426432
chevronLeft.events.onInputDown.add(function(e, pointer) {
427-
if (_this.options._onPrevCallback) {
428-
_this.options._onPrevCallback();
433+
if (_this.options._onPrePrevCallback) {
434+
_this.options._onPrePrevCallback();
429435
}
430436

431437
if (_this.tweenObj.isRunning !== true) {
432438
_this.stopSlider();
433439
_this.goToPrev();
434440
}
441+
442+
if (_this.options._onAfterPrevCallback) {
443+
_this.options._onAfterPrevCallback();
444+
}
435445

436446
}, _this);
437447

0 commit comments

Comments
 (0)