Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
I
i20rzslider
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jedife
i20rzslider
Commits
64e8a942
Commit
64e8a942
authored
Aug 02, 2016
by
Valentin Hervieu
Committed by
GitHub
Aug 02, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for #377 (#378)
* Add unit test showing the issue * Fix the issue
parent
c7b11698
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
102 additions
and
65 deletions
+102
-65
rzslider.js
dist/rzslider.js
+31
-32
rzslider.min.js
dist/rzslider.min.js
+2
-2
rzslider.js
src/rzslider.js
+30
-31
minMaxRange-noSwitching-range-slider-horizontal-test.js
...s/minMaxRange-noSwitching-range-slider-horizontal-test.js
+39
-0
No files found.
dist/rzslider.js
View file @
64e8a942
/*! angularjs-slider - v5.4.1 -
(c) Rafal Zajac <rzajac@gmail.com>, Valentin Hervieu <valentin@hervieu.me>, Jussi Saarivirta <jusasi@gmail.com>, Angelin Sirbu <angelin.sirbu@gmail.com> -
https://github.com/angular-slider/angularjs-slider -
2016-0
7-17
*/
2016-0
8-01
*/
/*jslint unparam: true */
/*global angular: false, console: false, define, module */
(
function
(
root
,
factory
)
{
...
...
@@ -792,7 +792,10 @@
label
.
rzsv
=
valStr
;
}
if
(
!
noLabelInjection
){
label
.
html
(
valStr
);
};
if
(
!
noLabelInjection
)
{
label
.
html
(
valStr
);
}
;
this
.
scope
[
which
+
'Label'
]
=
valStr
;
...
...
@@ -933,7 +936,7 @@
'background-color'
:
this
.
getSelectionBarColor
()
};
}
if
(
!
tick
.
selected
&&
this
.
options
.
getTickColor
)
{
if
(
!
tick
.
selected
&&
this
.
options
.
getTickColor
)
{
tick
.
style
=
{
'background-color'
:
this
.
getTickColor
(
value
)
}
...
...
@@ -1098,7 +1101,7 @@
shFloorCeil
:
function
()
{
// Show based only on hideLimitLabels if pointer labels are hidden
if
(
this
.
options
.
hidePointerLabels
)
{
return
;
return
;
}
var
flHidden
=
false
,
clHidden
=
false
,
...
...
@@ -1937,40 +1940,36 @@
valueChanged
=
true
;
}
else
{
if
(
this
.
options
.
noSwitching
)
{
if
(
this
.
tracking
===
'lowValue'
&&
newValue
>
this
.
highValue
)
newValue
=
this
.
applyMinMaxRange
(
this
.
highValue
);
else
if
(
this
.
tracking
===
'highValue'
&&
newValue
<
this
.
lowValue
)
newValue
=
this
.
applyMinMaxRange
(
this
.
lowValue
);
}
newValue
=
this
.
applyMinMaxRange
(
newValue
);
/* This is to check if we need to switch the min and max handles */
if
(
this
.
tracking
===
'lowValue'
&&
newValue
>
this
.
highValue
)
{
if
(
this
.
options
.
noSwitching
&&
this
.
highValue
!==
this
.
minValue
)
{
newValue
=
this
.
applyMinMaxRange
(
this
.
highValue
);
}
else
{
this
.
lowValue
=
this
.
highValue
;
this
.
applyLowValue
();
this
.
updateHandles
(
this
.
tracking
,
this
.
maxH
.
rzsp
);
this
.
updateAriaAttributes
();
this
.
tracking
=
'highValue'
;
this
.
minH
.
removeClass
(
'rz-active'
);
this
.
maxH
.
addClass
(
'rz-active'
);
if
(
this
.
options
.
keyboardSupport
)
this
.
focusElement
(
this
.
maxH
);
}
this
.
lowValue
=
this
.
highValue
;
this
.
applyLowValue
();
this
.
updateHandles
(
this
.
tracking
,
this
.
maxH
.
rzsp
);
this
.
updateAriaAttributes
();
this
.
tracking
=
'highValue'
;
this
.
minH
.
removeClass
(
'rz-active'
);
this
.
maxH
.
addClass
(
'rz-active'
);
if
(
this
.
options
.
keyboardSupport
)
this
.
focusElement
(
this
.
maxH
);
valueChanged
=
true
;
}
else
if
(
this
.
tracking
===
'highValue'
&&
newValue
<
this
.
lowValue
)
{
if
(
this
.
options
.
noSwitching
&&
this
.
lowValue
!==
this
.
maxValue
)
{
newValue
=
this
.
applyMinMaxRange
(
this
.
lowValue
);
}
else
{
this
.
highValue
=
this
.
lowValue
;
this
.
applyHighValue
();
this
.
updateHandles
(
this
.
tracking
,
this
.
minH
.
rzsp
);
this
.
updateAriaAttributes
();
this
.
tracking
=
'lowValue'
;
this
.
maxH
.
removeClass
(
'rz-active'
);
this
.
minH
.
addClass
(
'rz-active'
);
if
(
this
.
options
.
keyboardSupport
)
this
.
focusElement
(
this
.
minH
);
}
this
.
highValue
=
this
.
lowValue
;
this
.
applyHighValue
();
this
.
updateHandles
(
this
.
tracking
,
this
.
minH
.
rzsp
);
this
.
updateAriaAttributes
();
this
.
tracking
=
'lowValue'
;
this
.
maxH
.
removeClass
(
'rz-active'
);
this
.
minH
.
addClass
(
'rz-active'
);
if
(
this
.
options
.
keyboardSupport
)
this
.
focusElement
(
this
.
minH
);
valueChanged
=
true
;
}
}
...
...
dist/rzslider.min.js
View file @
64e8a942
This diff is collapsed.
Click to expand it.
src/rzslider.js
View file @
64e8a942
...
...
@@ -796,7 +796,10 @@
label
.
rzsv
=
valStr
;
}
if
(
!
noLabelInjection
){
label
.
html
(
valStr
);
};
if
(
!
noLabelInjection
)
{
label
.
html
(
valStr
);
}
;
this
.
scope
[
which
+
'Label'
]
=
valStr
;
...
...
@@ -937,7 +940,7 @@
'background-color'
:
this
.
getSelectionBarColor
()
};
}
if
(
!
tick
.
selected
&&
this
.
options
.
getTickColor
)
{
if
(
!
tick
.
selected
&&
this
.
options
.
getTickColor
)
{
tick
.
style
=
{
'background-color'
:
this
.
getTickColor
(
value
)
}
...
...
@@ -1102,7 +1105,7 @@
shFloorCeil
:
function
()
{
// Show based only on hideLimitLabels if pointer labels are hidden
if
(
this
.
options
.
hidePointerLabels
)
{
return
;
return
;
}
var
flHidden
=
false
,
clHidden
=
false
,
...
...
@@ -1941,40 +1944,36 @@
valueChanged
=
true
;
}
else
{
if
(
this
.
options
.
noSwitching
)
{
if
(
this
.
tracking
===
'lowValue'
&&
newValue
>
this
.
highValue
)
newValue
=
this
.
applyMinMaxRange
(
this
.
highValue
);
else
if
(
this
.
tracking
===
'highValue'
&&
newValue
<
this
.
lowValue
)
newValue
=
this
.
applyMinMaxRange
(
this
.
lowValue
);
}
newValue
=
this
.
applyMinMaxRange
(
newValue
);
/* This is to check if we need to switch the min and max handles */
if
(
this
.
tracking
===
'lowValue'
&&
newValue
>
this
.
highValue
)
{
if
(
this
.
options
.
noSwitching
&&
this
.
highValue
!==
this
.
minValue
)
{
newValue
=
this
.
applyMinMaxRange
(
this
.
highValue
);
}
else
{
this
.
lowValue
=
this
.
highValue
;
this
.
applyLowValue
();
this
.
updateHandles
(
this
.
tracking
,
this
.
maxH
.
rzsp
);
this
.
updateAriaAttributes
();
this
.
tracking
=
'highValue'
;
this
.
minH
.
removeClass
(
'rz-active'
);
this
.
maxH
.
addClass
(
'rz-active'
);
if
(
this
.
options
.
keyboardSupport
)
this
.
focusElement
(
this
.
maxH
);
}
this
.
lowValue
=
this
.
highValue
;
this
.
applyLowValue
();
this
.
updateHandles
(
this
.
tracking
,
this
.
maxH
.
rzsp
);
this
.
updateAriaAttributes
();
this
.
tracking
=
'highValue'
;
this
.
minH
.
removeClass
(
'rz-active'
);
this
.
maxH
.
addClass
(
'rz-active'
);
if
(
this
.
options
.
keyboardSupport
)
this
.
focusElement
(
this
.
maxH
);
valueChanged
=
true
;
}
else
if
(
this
.
tracking
===
'highValue'
&&
newValue
<
this
.
lowValue
)
{
if
(
this
.
options
.
noSwitching
&&
this
.
lowValue
!==
this
.
maxValue
)
{
newValue
=
this
.
applyMinMaxRange
(
this
.
lowValue
);
}
else
{
this
.
highValue
=
this
.
lowValue
;
this
.
applyHighValue
();
this
.
updateHandles
(
this
.
tracking
,
this
.
minH
.
rzsp
);
this
.
updateAriaAttributes
();
this
.
tracking
=
'lowValue'
;
this
.
maxH
.
removeClass
(
'rz-active'
);
this
.
minH
.
addClass
(
'rz-active'
);
if
(
this
.
options
.
keyboardSupport
)
this
.
focusElement
(
this
.
minH
);
}
this
.
highValue
=
this
.
lowValue
;
this
.
applyHighValue
();
this
.
updateHandles
(
this
.
tracking
,
this
.
minH
.
rzsp
);
this
.
updateAriaAttributes
();
this
.
tracking
=
'lowValue'
;
this
.
maxH
.
removeClass
(
'rz-active'
);
this
.
minH
.
addClass
(
'rz-active'
);
if
(
this
.
options
.
keyboardSupport
)
this
.
focusElement
(
this
.
minH
);
valueChanged
=
true
;
}
}
...
...
tests/specs/mouse-controls/minMaxRange-noSwitching-range-slider-horizontal-test.js
View file @
64e8a942
...
...
@@ -28,6 +28,7 @@
floor
:
0
,
ceil
:
100
,
minRange
:
10
,
maxRange
:
50
,
noSwitching
:
true
}
};
...
...
@@ -81,6 +82,44 @@
expect
(
helper
.
scope
.
slider
.
min
).
to
.
equal
(
45
);
expect
(
helper
.
scope
.
slider
.
max
).
to
.
equal
(
55
);
});
it
(
'should not modify any value if new range would be larger than maxRange when moving minH'
,
function
()
{
helper
.
fireMousedown
(
helper
.
slider
.
minH
,
0
);
var
expectedValue
=
0
;
helper
.
moveMouseToValue
(
expectedValue
);
expect
(
helper
.
scope
.
slider
.
min
).
to
.
equal
(
5
);
});
it
(
'should not modify any value if new range would be larger than maxRange when moving maxH'
,
function
()
{
helper
.
fireMousedown
(
helper
.
slider
.
maxH
,
0
);
var
expectedValue
=
100
;
helper
.
moveMouseToValue
(
expectedValue
);
expect
(
helper
.
scope
.
slider
.
max
).
to
.
equal
(
95
);
});
it
(
'should not switch min/max when moving minH far higher than maxH (issue #377)'
,
function
()
{
helper
.
scope
.
slider
.
min
=
0
;
helper
.
scope
.
slider
.
max
=
10
;
helper
.
scope
.
$digest
();
helper
.
fireMousedown
(
helper
.
slider
.
minH
,
0
);
var
expectedValue
=
100
;
helper
.
moveMouseToValue
(
expectedValue
);
expect
(
helper
.
scope
.
slider
.
min
).
to
.
equal
(
0
);
expect
(
helper
.
scope
.
slider
.
max
).
to
.
equal
(
10
);
});
it
(
'should not switch min/max when moving maxH far lower than minH (issue #377)'
,
function
()
{
helper
.
scope
.
slider
.
min
=
90
;
helper
.
scope
.
slider
.
max
=
100
;
helper
.
scope
.
$digest
();
helper
.
fireMousedown
(
helper
.
slider
.
maxH
,
0
);
var
expectedValue
=
0
;
helper
.
moveMouseToValue
(
expectedValue
);
expect
(
helper
.
scope
.
slider
.
min
).
to
.
equal
(
90
);
expect
(
helper
.
scope
.
slider
.
max
).
to
.
equal
(
100
);
});
});
describe
(
'Right to left Mouse controls - minRange and noSwitching Range Horizontal'
,
function
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment