@@ -53,7 +53,6 @@ phaseSlider = function (game) {
53
53
_this . tweenObj . onComplete . add ( function ( ) {
54
54
this . locked = false ;
55
55
this . slideIndex += 1 ;
56
-
57
56
if ( _this . options . autoAnimate === false && this . slideIndex >= _this . options . _objects . length - 1 ) {
58
57
if ( _this . options . _showHandles === true ) {
59
58
this . sliderControlsGroup . children [ 0 ] . alpha = 0 ;
@@ -280,17 +279,35 @@ phaseSlider = function (game) {
280
279
sliderBGAlpha : options . sliderBGAlpha || 1 ,
281
280
_customHandleNext : options . customHandleNext || "" ,
282
281
_customHandlePrev : options . customHandlePrev || "" ,
283
- _showHandles : options . showHandles || true ,
282
+ _showHandles : options . showHandles == undefined ? true : options . showHandles ,
284
283
_onNextCallback : options . onNextCallback || false ,
285
- _onPrevCallback : options . onPrevCallback || false
284
+ _onPrevCallback : options . onPrevCallback || false ,
285
+ _addModal : options . modal || false ,
286
+ _modalAlpha : options . modalAlpha || 0.7 ,
287
+ _staticElements : options . staticElements || [ ]
286
288
} ;
287
289
288
290
//////////////////////////////////////////////////////////////////////////////////////////////
289
291
290
292
var bgRect ;
293
+ _this . _modal = { } ;
294
+ if ( _this . options . _addModal === true ) {
295
+ _this . _modal = game . add . graphics ( game . width , game . height ) ;
296
+ _this . _modal . beginFill ( 0x000000 , _this . options . _modalAlpha ) ;
297
+ _this . _modal . x = 0 ;
298
+ _this . _modal . y = 0 ;
299
+ _this . _modal . inputEnabled = true ;
300
+ _this . _modal . drawRect ( 0 , 0 , _this . game . width , _this . game . height ) ;
301
+ }
302
+ else {
303
+ _this . _modal = false ;
304
+ }
291
305
292
306
//////// OBJECTS GROUP
307
+ ///
308
+ _this . sliderBGGroup = _this . game . add . group ( ) ;
293
309
_this . sliderMainGroup = _this . game . add . group ( ) ;
310
+ _this . sliderBGGroup . width = _this . options . _width ;
294
311
_this . sliderMainGroup . width = _this . options . _width ;
295
312
if ( _this . options . _mode === "horizontal" ) {
296
313
_this . sliderMainGroup . width = _this . options . _width * _this . options . _objects . length ;
@@ -310,6 +327,10 @@ phaseSlider = function (game) {
310
327
_this . sliderMainGroup . height = _this . options . _height ;
311
328
_this . sliderMainGroup . x = _this . options . _x ;
312
329
_this . sliderMainGroup . y = _this . options . _y ;
330
+ //
331
+ _this . sliderBGGroup . height = _this . options . _height ;
332
+ _this . sliderBGGroup . x = _this . options . _x ;
333
+ _this . sliderBGGroup . y = _this . options . _y ;
313
334
314
335
/// DRAG for horizontal
315
336
/*var draggableSprite = _this.game.add.sprite(_this.options._x, _this.options._y);
@@ -352,7 +373,7 @@ phaseSlider = function (game) {
352
373
bgRect . drawRect ( 0 , 0 , _this . options . _width , _this . options . _height ) ;
353
374
_this . sliderMainGroup . add ( bgRect ) ;
354
375
} else {
355
- _this . sliderMainGroup . add ( _this . options . customSliderBG ) ;
376
+ _this . sliderBGGroup . add ( _this . options . customSliderBG ) ;
356
377
}
357
378
// add controls
358
379
if ( _this . options . _showHandles === true ) {
@@ -410,26 +431,43 @@ phaseSlider = function (game) {
410
431
chevronLeft . alpha = 0 ;
411
432
}
412
433
}
434
+ else {
435
+
436
+ }
413
437
414
438
415
439
// ADDING THE BLOCKS
416
440
if ( _this . options . _objects . length > 0 ) {
417
- for ( var i = 0 ; i < _this . options . _objects . length ; i ++ ) {
441
+ var objArr = _this . options . _objects . slice ( 0 ) ;
442
+ var length = Number ( objArr . length ) ;
443
+ for ( var i = 0 ; i < length ; i ++ ) {
418
444
var x ;
419
445
var y ;
420
446
// mode
421
447
if ( _this . options . _mode === "horizontal" ) {
422
- _this . options . _objects [ i ] . x = ( _this . options . _width * i ) ;
448
+ objArr [ i ] . x = ( _this . options . _width * i ) ;
423
449
} else if ( _this . options . _mode === "vertical-from-top" ) {
424
- _this . options . _objects [ i ] . y = ( _this . options . _height * i ) * - 1 ;
450
+ objArr [ i ] . y = ( _this . options . _height * i ) * - 1 ;
425
451
426
452
} else if ( _this . options . _mode === "vertical-from-bottom" ) {
427
- _this . options . _objects [ i ] . y = ( _this . options . _height * i ) ;
453
+ objArr [ i ] . y = ( _this . options . _height * i ) ;
428
454
}
429
- _this . sliderMainGroup . add ( _this . options . _objects [ i ] ) ;
455
+ _this . sliderMainGroup . add ( objArr [ i ] ) ;
430
456
}
457
+ _this . options . _objects = _this . sliderMainGroup . children ;
458
+ //window.console.log(_this.options._objects.length, _this.options._objects, _this.sliderMainGroup.children.length);
431
459
}
432
460
461
+
462
+ // ADDING STATIC ELEMENTS
463
+ if ( _this . options . _staticElements . length > 0 ) {
464
+ for ( var i = 0 ; i < _this . options . _staticElements . length ; i ++ ) {
465
+ game . world . bringToTop ( _this . options . _staticElements [ i ] ) ;
466
+ _this . sliderBGGroup . add ( _this . options . _staticElements [ i ] ) ;
467
+ }
468
+ }
469
+
470
+
433
471
// move the chevrons to top
434
472
if ( _this . options . _showHandles === true ) {
435
473
_this . sliderControlsGroup . add ( chevronRight ) ;
@@ -461,13 +499,28 @@ phaseSlider = function (game) {
461
499
getCurrentIndex : function ( ) {
462
500
return _this . slideIndex ;
463
501
} ,
502
+ refreshSlider : function ( ) {
503
+
504
+ } ,
505
+ removeItemAt : function ( index ) {
506
+ _this . sliderMainGroup . removeChildAt ( index ) ;
507
+ _this . options . _objects = _this . sliderMainGroup . children ;
508
+ } ,
464
509
hideSlider : function ( ) {
465
510
_this . sliderMainGroup . visible = false ;
466
511
_this . sliderControlsGroup . visible = false ;
512
+ _this . sliderBGGroup . visible = false ;
513
+ if ( _this . _modal ) {
514
+ _this . _modal . visible = false ;
515
+ }
467
516
} ,
468
517
showSlider : function ( ) {
469
518
_this . sliderMainGroup . visible = true ;
470
519
_this . sliderControlsGroup . visible = true ;
520
+ _this . sliderBGGroup . visible = true ;
521
+ if ( _this . _modal ) {
522
+ _this . _modal . visible = true ;
523
+ }
471
524
}
472
525
} ;
473
- } ;
526
+ } ;
0 commit comments