44 * (c) Rafal Zajac <[email protected] > 55 * http://github.com/rzajac/angularjs-slider
66 *
7- * Version: v0.1.33
7+ * Version: v0.1.34
88 *
99 * Licensed under the MIT license
1010 */
@@ -296,8 +296,6 @@ function throttle(func, wait, options) {
296296 self . updateFloorLab ( ) ;
297297 self . initHandles ( ) ;
298298 if ( ! self . presentOnly ) { self . bindEvents ( ) ; }
299- if ( self . showTicks )
300- self . updateTicksScale ( ) ;
301299 } ) ;
302300
303301 // Recalculate slider view dimensions
@@ -316,6 +314,7 @@ function throttle(func, wait, options) {
316314 self . setMinAndMax ( ) ;
317315 self . updateLowHandle ( self . valueToOffset ( self . scope . rzSliderModel ) ) ;
318316 self . updateSelectionBar ( ) ;
317+ self . updateTicksScale ( ) ;
319318
320319 if ( self . range )
321320 {
@@ -329,6 +328,7 @@ function throttle(func, wait, options) {
329328 self . setMinAndMax ( ) ;
330329 self . updateHighHandle ( self . valueToOffset ( self . scope . rzSliderHigh ) ) ;
331330 self . updateSelectionBar ( ) ;
331+ self . updateTicksScale ( ) ;
332332 self . updateCmbLabel ( ) ;
333333 } , 350 , { leading : false } ) ;
334334
@@ -438,6 +438,7 @@ function throttle(func, wait, options) {
438438 }
439439
440440 this . updateSelectionBar ( ) ;
441+ this . updateTicksScale ( ) ;
441442 } ,
442443
443444 /**
@@ -605,8 +606,6 @@ function throttle(func, wait, options) {
605606
606607 this . getWidth ( this . sliderElem ) ;
607608 this . sliderElem . rzsl = this . sliderElem [ 0 ] . getBoundingClientRect ( ) . left ;
608- if ( this . showTicks )
609- this . updateTicksScale ( ) ;
610609
611610 if ( this . initHasRun )
612611 {
@@ -621,16 +620,27 @@ function throttle(func, wait, options) {
621620 * @returns {undefined }
622621 */
623622 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 ;
634644 } ,
635645
636646 /**
@@ -710,6 +720,7 @@ function throttle(func, wait, options) {
710720 {
711721 this . updateLowHandle ( newOffset ) ;
712722 this . updateSelectionBar ( ) ;
723+ this . updateTicksScale ( ) ;
713724
714725 if ( this . range )
715726 {
@@ -722,6 +733,7 @@ function throttle(func, wait, options) {
722733 {
723734 this . updateHighHandle ( newOffset ) ;
724735 this . updateSelectionBar ( ) ;
736+ this . updateTicksScale ( ) ;
725737
726738 if ( this . range )
727739 {
@@ -734,6 +746,7 @@ function throttle(func, wait, options) {
734746 this . updateLowHandle ( newOffset ) ;
735747 this . updateHighHandle ( newOffset ) ;
736748 this . updateSelectionBar ( ) ;
749+ this . updateTicksScale ( ) ;
737750 this . updateCmbLabel ( ) ;
738751 } ,
739752
0 commit comments