Skip to content

Commit 4e3fba1

Browse files
committed
fix a view bug
reason: when the *ceil value* is `0` and the *model value* is `0`, the `valueToOffset` function returns `NaN`. And the *low handle* label has a litter poor display. the `single.html` shows the problem
1 parent 43acfc8 commit 4e3fba1

File tree

4 files changed

+73
-3
lines changed

4 files changed

+73
-3
lines changed

demo/single.html

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<!DOCTYPE html>
2+
<html ng-app="rzSliderDemo">
3+
4+
<head>
5+
<meta charset="utf-8"/>
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<title>AngularJS Touch Slider</title>
8+
<link rel="stylesheet" href="demo.css"/>
9+
<link rel="stylesheet" href="../dist/rzslider.css"/>
10+
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300,400,700' rel='stylesheet' type='text/css'>
11+
</head>
12+
13+
<body ng-controller="MainCtrl">
14+
15+
<div class="wrapper">
16+
<header>
17+
<h1>AngularJS Touch Slider Toggle case</h1>
18+
</header>
19+
20+
<article>
21+
<h2>Toggle slider example</h2>
22+
<button ng-click="toggle()">Show</button>
23+
<button ng-click="toggleCeil()">toggle ceil</button>
24+
<div ng-show="visible">
25+
<rzslider rz-slider-model="toggleSlider.value"
26+
rz-slider-floor="toggleSlider.floor"
27+
rz-slider-hide-limit-labels="true"
28+
rz-slider-ceil="toggleSlider.ceil"></rzslider>
29+
</div>
30+
</article>
31+
32+
</div>
33+
34+
35+
<script src="../bower_components/angular/angular.js"></script>
36+
<script src="../dist/rzslider.js"></script>
37+
<script>
38+
var app = angular.module('rzSliderDemo', ['rzModule']);
39+
40+
app.controller('MainCtrl', function($scope, $timeout) {
41+
42+
43+
$scope.visible = false;
44+
45+
$scope.toggle = function() {
46+
$scope.visible = !$scope.visible;
47+
$timeout(function() {
48+
$scope.$broadcast('rzSliderForceRender');
49+
});
50+
};
51+
52+
$scope.toggleCeil = function() {
53+
$scope.toggleSlider.ceil = $scope.toggleSlider.ceil?0:500;
54+
/*$timeout(function() {
55+
$scope.$broadcast('rzSliderForceRender');
56+
});*/
57+
};
58+
59+
$scope.toggleSlider = {
60+
value: 0,
61+
ceil: 0,
62+
floor: 0
63+
};
64+
});
65+
</script>
66+
67+
</body>
68+
69+
70+
</html>

dist/rzslider.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ function throttle(func, wait, options) {
897897
*/
898898
valueToOffset: function(val)
899899
{
900-
return (val - this.minValue) * this.maxLeft / this.valueRange;
900+
return (val - this.minValue) * this.maxLeft / this.valueRange || 0;
901901
},
902902

903903
/**

0 commit comments

Comments
 (0)