Skip to content

Commit 3befa4d

Browse files
committed
Fix #26
1 parent 073809b commit 3befa4d

File tree

8 files changed

+41
-19
lines changed

8 files changed

+41
-19
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ $scope.priceSlider = {
9494

9595
> Set to true to hide min / max labels
9696
97+
**rz-slider-always-show-bar**
98+
99+
> Set to true to always show selection bar
100+
97101
**rz-slider-translate**
98102

99103
> Custom translate function. Use this if you want to translate values displayed on the slider. For example if you want to display dollar amounts instead of just numbers do this:

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angularjs-slider",
3-
"version": "0.1.11",
3+
"version": "0.1.12",
44
"homepage": "https://github.com/rzajac/angularjs-slider",
55
"authors": [
66
"Rafal Zajac <[email protected]>",

demo/demo.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ body { font-family: 'Open Sans', sans-serif; color: #1f2636; font-size: 14px; }
33
header { background: #0db9f0; color: #fff; margin: -40px; margin-bottom: 40px; text-align: center; padding: 40px 0; }
44
h1 { font-weight: 300; }
55
.wrapper { background: #fff; padding: 40px; }
6-
article { margin-bottom: 40px; }
6+
article { margin-bottom: 40px; }
7+

demo/index.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ <h2>Min/max slider example</h2>
3333
</article>
3434

3535
<article>
36-
<h2>One value slider example</h2>
36+
<h2>Currency slider example</h2>
3737

3838
Value: {{ priceSlider2 | json }}
3939
<rzslider
@@ -44,12 +44,13 @@ <h2>One value slider example</h2>
4444
</article>
4545

4646
<article>
47-
<h2>Currency slider example</h2>
47+
<h2>One value slider example</h2>
4848

49-
Value: {{ priceSlider2 | json }}
49+
Value: {{ priceSlider3 | json }}
5050
<rzslider rz-slider-model="priceSlider3"
5151
rz-slider-floor="50"
52-
rz-slider-ceil="450"></rzslider>
52+
rz-slider-ceil="450"
53+
rz-slider-always-show-bar="true"></rzslider>
5354
</article>
5455

5556
<article>

dist/rzslider.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rzslider.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jusas-angularjs-slider",
3-
"version": "0.1.11",
3+
"version": "0.1.12",
44
"description": "AngularJS slider directive with no external dependencies. Mobile friendly!.",
55
"main": "rzslider.js",
66
"repository": {

rzslider.js

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* (c) Rafal Zajac <[email protected]>
55
* http://github.com/rzajac/angularjs-slider
66
*
7-
* Version: v0.1.11
7+
* Version: v0.1.12
88
*
99
* Licensed under the MIT license
1010
*/
@@ -31,7 +31,7 @@ function throttle(func, wait, options) {
3131
var context, args, result;
3232
var timeout = null;
3333
var previous = 0;
34-
options || (options = {});
34+
options = options || {};
3535
var later = function() {
3636
previous = options.leading === false ? 0 : getTime();
3737
timeout = null;
@@ -104,6 +104,13 @@ function throttle(func, wait, options) {
104104
*/
105105
this.handleHalfWidth = 0;
106106

107+
/**
108+
* Always show selection bar
109+
*
110+
* @type {string|boolean}
111+
*/
112+
this.alwaysShowBar = attributes.rzSliderAlwaysShowBar || false;
113+
107114
/**
108115
* Maximum left the slider handle can have
109116
*
@@ -237,10 +244,10 @@ function throttle(func, wait, options) {
237244
{
238245
self.setMinAndMax();
239246
self.updateLowHandle(self.valueToOffset(self.scope.rzSliderModel));
247+
self.updateSelectionBar();
240248

241249
if(self.range)
242250
{
243-
self.updateSelectionBar();
244251
self.updateCmbLabel();
245252
}
246253

@@ -340,9 +347,10 @@ function throttle(func, wait, options) {
340347
if(this.range)
341348
{
342349
this.updateHighHandle(this.valueToOffset(this.scope.rzSliderHigh));
343-
this.updateSelectionBar();
344350
this.updateCmbLabel();
345351
}
352+
353+
this.updateSelectionBar();
346354
},
347355

348356
/**
@@ -453,6 +461,10 @@ function throttle(func, wait, options) {
453461
this.cmbLab.remove();
454462
this.maxLab.remove();
455463
this.maxH.remove();
464+
}
465+
466+
if( !this.range && !this.alwaysShowBar)
467+
{
456468
this.selBar.remove();
457469
}
458470
},
@@ -517,9 +529,10 @@ function throttle(func, wait, options) {
517529
if(which === 'rzSliderModel')
518530
{
519531
this.updateLowHandle(newOffset);
532+
this.updateSelectionBar();
533+
520534
if(this.range)
521535
{
522-
this.updateSelectionBar();
523536
this.updateCmbLabel();
524537
}
525538
return;
@@ -528,9 +541,10 @@ function throttle(func, wait, options) {
528541
if(which === 'rzSliderHigh')
529542
{
530543
this.updateHighHandle(newOffset);
544+
this.updateSelectionBar();
545+
531546
if(this.range)
532547
{
533-
this.updateSelectionBar();
534548
this.updateCmbLabel();
535549
}
536550
return;
@@ -634,8 +648,8 @@ function throttle(func, wait, options) {
634648
*/
635649
updateSelectionBar: function()
636650
{
637-
this.setWidth(this.selBar, this.maxH.rzsl - this.minH.rzsl);
638-
this.setLeft(this.selBar, this.minH.rzsl + this.handleHalfWidth);
651+
this.setWidth(this.selBar, Math.abs(this.maxH.rzsl - this.minH.rzsl));
652+
this.setLeft(this.selBar, this.range ? this.minH.rzsl + this.handleHalfWidth : 0);
639653
},
640654

641655
/**
@@ -938,7 +952,8 @@ function throttle(func, wait, options) {
938952
rzSliderModel: '=?',
939953
rzSliderHigh: '=?',
940954
rzSliderTranslate: '&',
941-
rzSliderHideLimitLabels: '=?'
955+
rzSliderHideLimitLabels: '=?',
956+
rzSliderAlwaysShowBar: '=?'
942957
},
943958
template: '<span class="rz-bar"></span>' + // 0 The slider bar
944959
'<span class="rz-bar rz-selection"></span>' + // 1 Highlight between two handles
@@ -980,6 +995,7 @@ function throttle(func, wait, options) {
980995
/**
981996
* @name Event
982997
* @property {Array} touches
998+
* @property {Event} originalEvent
983999
*/
9841000

9851001
/**

0 commit comments

Comments
 (0)