4
4
* (c) Rafal Zajac <[email protected] >
5
5
* http://github.com/rzajac/angularjs-slider
6
6
*
7
- * Version: v0.1.33
7
+ * Version: v0.1.34
8
8
*
9
9
* Licensed under the MIT license
10
10
*/
@@ -296,8 +296,6 @@ function throttle(func, wait, options) {
296
296
self . updateFloorLab ( ) ;
297
297
self . initHandles ( ) ;
298
298
if ( ! self . presentOnly ) { self . bindEvents ( ) ; }
299
- if ( self . showTicks )
300
- self . updateTicksScale ( ) ;
301
299
} ) ;
302
300
303
301
// Recalculate slider view dimensions
@@ -316,6 +314,7 @@ function throttle(func, wait, options) {
316
314
self . setMinAndMax ( ) ;
317
315
self . updateLowHandle ( self . valueToOffset ( self . scope . rzSliderModel ) ) ;
318
316
self . updateSelectionBar ( ) ;
317
+ self . updateTicksScale ( ) ;
319
318
320
319
if ( self . range )
321
320
{
@@ -329,6 +328,7 @@ function throttle(func, wait, options) {
329
328
self . setMinAndMax ( ) ;
330
329
self . updateHighHandle ( self . valueToOffset ( self . scope . rzSliderHigh ) ) ;
331
330
self . updateSelectionBar ( ) ;
331
+ self . updateTicksScale ( ) ;
332
332
self . updateCmbLabel ( ) ;
333
333
} , 350 , { leading : false } ) ;
334
334
@@ -438,6 +438,7 @@ function throttle(func, wait, options) {
438
438
}
439
439
440
440
this . updateSelectionBar ( ) ;
441
+ this . updateTicksScale ( ) ;
441
442
} ,
442
443
443
444
/**
@@ -605,8 +606,6 @@ function throttle(func, wait, options) {
605
606
606
607
this . getWidth ( this . sliderElem ) ;
607
608
this . sliderElem . rzsl = this . sliderElem [ 0 ] . getBoundingClientRect ( ) . left ;
608
- if ( this . showTicks )
609
- this . updateTicksScale ( ) ;
610
609
611
610
if ( this . initHasRun )
612
611
{
@@ -621,16 +620,27 @@ function throttle(func, wait, options) {
621
620
* @returns {undefined }
622
621
*/
623
622
updateTicksScale : function ( ) {
624
- if ( ! this . step ) return ; //if step is 0, the following loop will be endless.
625
-
626
- var positions = '' ;
627
- for ( var i = this . minValue ; i <= this . maxValue ; i += this . step ) {
628
- positions += '<li class="tick">' ;
629
- if ( this . showTicksValue )
630
- positions += '<span class="tick-value">' + this . getDisplayValue ( i ) + '</span>' ;
631
- positions += '</li>' ;
632
- }
633
- this . ticks . html ( positions ) ;
623
+ if ( ! this . showTicks ) return ;
624
+ if ( ! this . step ) return ; //if step is 0, the following loop will be endless.
625
+
626
+ var positions = '' ;
627
+ for ( var i = this . minValue ; i <= this . maxValue ; i += this . step ) {
628
+ var selectedClass = this . isTickSelected ( i ) ? 'selected' : false ;
629
+ positions += '<li class="tick ' + selectedClass + '">' ;
630
+ if ( this . showTicksValue )
631
+ positions += '<span class="tick-value">' + this . getDisplayValue ( i ) + '</span>' ;
632
+ positions += '</li>' ;
633
+ }
634
+ this . ticks . html ( positions ) ;
635
+ } ,
636
+
637
+ isTickSelected : function ( value ) {
638
+ var tickLeft = this . valueToOffset ( value ) ;
639
+ if ( ! this . range && this . alwaysShowBar && value <= this . scope . rzSliderModel )
640
+ return true ;
641
+ if ( this . range && value >= this . scope . rzSliderModel && value <= this . scope . rzSliderHigh )
642
+ return true ;
643
+ return false ;
634
644
} ,
635
645
636
646
/**
@@ -710,6 +720,7 @@ function throttle(func, wait, options) {
710
720
{
711
721
this . updateLowHandle ( newOffset ) ;
712
722
this . updateSelectionBar ( ) ;
723
+ this . updateTicksScale ( ) ;
713
724
714
725
if ( this . range )
715
726
{
@@ -722,6 +733,7 @@ function throttle(func, wait, options) {
722
733
{
723
734
this . updateHighHandle ( newOffset ) ;
724
735
this . updateSelectionBar ( ) ;
736
+ this . updateTicksScale ( ) ;
725
737
726
738
if ( this . range )
727
739
{
@@ -734,6 +746,7 @@ function throttle(func, wait, options) {
734
746
this . updateLowHandle ( newOffset ) ;
735
747
this . updateHighHandle ( newOffset ) ;
736
748
this . updateSelectionBar ( ) ;
749
+ this . updateTicksScale ( ) ;
737
750
this . updateCmbLabel ( ) ;
738
751
} ,
739
752
0 commit comments