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
1d2354e5
Commit
1d2354e5
authored
Dec 05, 2015
by
Valentin Hervieu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start to implement the keyboard support
parent
06c08223
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
113 additions
and
17 deletions
+113
-17
rzslider.js
dist/rzslider.js
+55
-7
rzslider.min.css
dist/rzslider.min.css
+1
-1
rzslider.min.js
dist/rzslider.min.js
+2
-2
rzslider.js
src/rzslider.js
+55
-7
No files found.
dist/rzslider.js
View file @
1d2354e5
...
...
@@ -1014,16 +1014,16 @@
* @returns {number}
*/
valueToOffset
:
function
(
val
)
{
return
(
this
.
sanitize
Offset
Value
(
val
)
-
this
.
minValue
)
*
this
.
maxPos
/
this
.
valueRange
||
0
;
return
(
this
.
sanitizeValue
(
val
)
-
this
.
minValue
)
*
this
.
maxPos
/
this
.
valueRange
||
0
;
},
/**
*
Ensure that the position rendered is within the slider bounds, even if the value is not
*
Returns a value that is within slider range
*
* @param {number} val
* @returns {number}
*/
sanitize
Offset
Value
:
function
(
val
)
{
sanitizeValue
:
function
(
val
)
{
return
Math
.
min
(
Math
.
max
(
val
,
this
.
minValue
),
this
.
maxValue
);
},
...
...
@@ -1126,6 +1126,11 @@
this
.
selBar
.
on
(
'touchstart'
,
angular
.
bind
(
this
,
barMove
,
this
.
selBar
));
this
.
ticks
.
on
(
'touchstart'
,
angular
.
bind
(
this
,
this
.
onStart
,
null
,
null
));
this
.
ticks
.
on
(
'touchstart'
,
angular
.
bind
(
this
,
this
.
onMove
,
this
.
ticks
));
this
.
minH
.
on
(
'focus'
,
angular
.
bind
(
this
,
this
.
onPointerFocus
,
this
.
minH
,
'rzSliderModel'
))
if
(
this
.
range
)
{
this
.
maxH
.
on
(
'focus'
,
angular
.
bind
(
this
,
this
.
onPointerFocus
,
this
.
maxH
,
'rzSliderHigh'
));
}
},
/**
...
...
@@ -1156,10 +1161,6 @@
event
.
stopPropagation
();
event
.
preventDefault
();
if
(
this
.
tracking
!==
''
)
{
return
;
}
// We have to do this in case the HTML where the sliders are on
// have been animated into view.
this
.
calcViewDimensions
();
...
...
@@ -1210,6 +1211,49 @@
this
.
positionTrackingHandle
(
newValue
,
newOffset
);
},
onPointerFocus
:
function
(
pointer
,
ref
,
event
)
{
this
.
tracking
=
ref
;
pointer
.
one
(
'blur'
,
angular
.
bind
(
this
,
this
.
onPointerBlur
,
pointer
));
pointer
.
on
(
'keydown'
,
angular
.
bind
(
this
,
this
.
onKeyboardEvent
));
pointer
.
addClass
(
'rz-active'
);
},
onPointerBlur
:
function
(
pointer
,
event
)
{
this
.
tracking
=
''
;
pointer
.
off
(
'keydown'
);
pointer
.
removeClass
(
'rz-active'
);
},
onKeyboardEvent
:
function
(
event
)
{
var
keyCode
=
event
.
keyCode
||
event
.
which
,
keys
=
{
38
:
'UP'
,
40
:
'DOWN'
,
37
:
'LEFT'
,
39
:
'RIGHT'
},
actions
=
{
UP
:
5
,
DOWN
:
-
5
,
LEFT
:
-
1
,
RIGHT
:
1
},
key
=
keys
[
keyCode
],
action
=
actions
[
key
];
if
(
!
key
||
!
this
.
tracking
)
return
;
event
.
preventDefault
();
var
value
=
this
.
scope
[
this
.
tracking
],
newValue
=
this
.
roundStep
(
this
.
sanitizeValue
(
value
+
action
)),
newOffset
=
this
.
valueToOffset
(
newValue
);
var
switched
=
this
.
positionTrackingHandle
(
newValue
,
newOffset
);
if
(
switched
)
{
var
pointer
=
this
.
tracking
===
'rzSliderModel'
?
this
.
minH
:
this
.
maxH
;
pointer
[
0
].
focus
();
//to focus the correct pointer
}
},
/**
* onDragStart event handler
*
...
...
@@ -1302,10 +1346,12 @@
*/
positionTrackingHandle
:
function
(
newValue
,
newOffset
)
{
var
valueChanged
=
false
;
var
switched
=
false
;
if
(
this
.
range
)
{
/* This is to check if we need to switch the min and max handles*/
if
(
this
.
tracking
===
'rzSliderModel'
&&
newValue
>=
this
.
scope
.
rzSliderHigh
)
{
switched
=
true
;
this
.
scope
[
this
.
tracking
]
=
this
.
scope
.
rzSliderHigh
;
this
.
updateHandles
(
this
.
tracking
,
this
.
maxH
.
rzsp
);
this
.
tracking
=
'rzSliderHigh'
;
...
...
@@ -1313,6 +1359,7 @@
this
.
maxH
.
addClass
(
'rz-active'
);
valueChanged
=
true
;
}
else
if
(
this
.
tracking
===
'rzSliderHigh'
&&
newValue
<=
this
.
scope
.
rzSliderModel
)
{
switched
=
true
;
this
.
scope
[
this
.
tracking
]
=
this
.
scope
.
rzSliderModel
;
this
.
updateHandles
(
this
.
tracking
,
this
.
minH
.
rzsp
);
this
.
tracking
=
'rzSliderModel'
;
...
...
@@ -1332,6 +1379,7 @@
this
.
scope
.
$apply
();
this
.
callOnChange
();
}
return
switched
;
},
/**
...
...
dist/rzslider.min.css
View file @
1d2354e5
/*! angularjs-slider - v2.2.0 - (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/rzajac/angularjs-slider.git - 2015-12-1
7
*/
/*! angularjs-slider - v2.2.0 - (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/rzajac/angularjs-slider.git - 2015-12-1
8
*/
rzslider
{
position
:
relative
;
display
:
inline-block
;
width
:
100%
;
height
:
4px
;
margin
:
35px
0
15px
0
;
vertical-align
:
middle
;
-webkit-user-select
:
none
;
-moz-user-select
:
none
;
-ms-user-select
:
none
;
user-select
:
none
}
rzslider
[
disabled
]
{
cursor
:
not-allowed
}
rzslider
[
disabled
]
.rz-pointer
{
cursor
:
not-allowed
;
background-color
:
#d8e0f3
}
rzslider
span
{
position
:
absolute
;
display
:
inline-block
;
white-space
:
nowrap
}
rzslider
.rz-base
{
width
:
100%
;
height
:
100%
;
padding
:
0
}
rzslider
.rz-bar-wrapper
{
left
:
0
;
z-index
:
1
;
width
:
100%
;
height
:
32px
;
padding-top
:
16px
;
margin-top
:
-16px
;
box-sizing
:
border-box
}
rzslider
.rz-bar-wrapper.rz-draggable
{
cursor
:
move
}
rzslider
.rz-bar
{
left
:
0
;
z-index
:
1
;
width
:
100%
;
height
:
4px
;
background
:
#d8e0f3
;
-webkit-border-radius
:
2px
;
-moz-border-radius
:
2px
;
border-radius
:
2px
}
rzslider
.rz-bar.rz-selection
{
z-index
:
2
;
background
:
#0db9f0
;
-webkit-border-radius
:
2px
;
-moz-border-radius
:
2px
;
border-radius
:
2px
}
rzslider
.rz-pointer
{
top
:
-14px
;
z-index
:
3
;
width
:
32px
;
height
:
32px
;
cursor
:
pointer
;
background-color
:
#0db9f0
;
-webkit-border-radius
:
16px
;
-moz-border-radius
:
16px
;
border-radius
:
16px
}
rzslider
.rz-pointer
:after
{
position
:
absolute
;
top
:
12px
;
left
:
12px
;
width
:
8px
;
height
:
8px
;
background
:
#fff
;
-webkit-border-radius
:
4px
;
-moz-border-radius
:
4px
;
border-radius
:
4px
;
content
:
''
}
rzslider
.rz-pointer
:hover:after
{
background-color
:
#fff
}
rzslider
.rz-pointer.rz-active
:after
{
background-color
:
#451aff
}
rzslider
.rz-bubble
{
bottom
:
16px
;
padding
:
1px
3px
;
color
:
#55637d
;
cursor
:
default
}
rzslider
.rz-bubble.rz-selection
{
top
:
16px
}
rzslider
.rz-bubble.rz-limit
{
color
:
#55637d
}
rzslider
.rz-ticks
{
position
:
absolute
;
top
:
-3px
;
left
:
0
;
z-index
:
1
;
display
:
-webkit-flex
;
display
:
-ms-flexbox
;
display
:
flex
;
width
:
100%
;
padding
:
0
11px
;
margin
:
0
;
list-style
:
none
;
box-sizing
:
border-box
;
-webkit-justify-content
:
space-between
;
-ms-flex-pack
:
justify
;
justify-content
:
space-between
}
rzslider
.rz-ticks
.tick
{
width
:
10px
;
height
:
10px
;
text-align
:
center
;
cursor
:
pointer
;
background
:
#d8e0f3
;
border-radius
:
50%
}
rzslider
.rz-ticks
.tick.selected
{
background
:
#0db9f0
}
rzslider
.rz-ticks
.tick
.tick-value
{
position
:
absolute
;
top
:
-30px
;
transform
:
translate
(
-50%
,
0
)}
rzslider
.vertical
{
position
:
relative
;
width
:
4px
;
height
:
100%
;
padding
:
0
;
margin
:
0
20px
;
vertical-align
:
baseline
}
rzslider
.vertical
.rz-base
{
width
:
100%
;
height
:
100%
;
padding
:
0
}
rzslider
.vertical
.rz-bar-wrapper
{
top
:
auto
;
left
:
0
;
width
:
32px
;
height
:
100%
;
padding
:
0
0
0
16px
;
margin
:
0
0
0
-16px
}
rzslider
.vertical
.rz-bar
{
bottom
:
0
;
left
:
auto
;
width
:
4px
;
height
:
100%
}
rzslider
.vertical
.rz-pointer
{
top
:
auto
;
bottom
:
0
;
left
:
-14px
!important
}
rzslider
.vertical
.rz-bubble
{
bottom
:
0
;
left
:
16px
!important
;
margin-left
:
3px
}
rzslider
.vertical
.rz-bubble.rz-selection
{
top
:
auto
;
left
:
16px
!important
}
rzslider
.vertical
.rz-ticks
{
top
:
0
;
left
:
-3px
;
z-index
:
1
;
width
:
auto
;
height
:
100%
;
padding
:
11px
0
;
-webkit-flex-direction
:
column-reverse
;
-ms-flex-direction
:
column-reverse
;
flex-direction
:
column-reverse
}
rzslider
.vertical
.rz-ticks
.tick
{
vertical-align
:
middle
}
rzslider
.vertical
.rz-ticks
.tick
.tick-value
{
top
:
auto
;
right
:
-30px
;
transform
:
translate
(
0
,
-28%
)}
\ No newline at end of file
dist/rzslider.min.js
View file @
1d2354e5
This diff is collapsed.
Click to expand it.
src/rzslider.js
View file @
1d2354e5
...
...
@@ -1014,16 +1014,16 @@
* @returns {number}
*/
valueToOffset
:
function
(
val
)
{
return
(
this
.
sanitize
Offset
Value
(
val
)
-
this
.
minValue
)
*
this
.
maxPos
/
this
.
valueRange
||
0
;
return
(
this
.
sanitizeValue
(
val
)
-
this
.
minValue
)
*
this
.
maxPos
/
this
.
valueRange
||
0
;
},
/**
*
Ensure that the position rendered is within the slider bounds, even if the value is not
*
Returns a value that is within slider range
*
* @param {number} val
* @returns {number}
*/
sanitize
Offset
Value
:
function
(
val
)
{
sanitizeValue
:
function
(
val
)
{
return
Math
.
min
(
Math
.
max
(
val
,
this
.
minValue
),
this
.
maxValue
);
},
...
...
@@ -1126,6 +1126,11 @@
this
.
selBar
.
on
(
'touchstart'
,
angular
.
bind
(
this
,
barMove
,
this
.
selBar
));
this
.
ticks
.
on
(
'touchstart'
,
angular
.
bind
(
this
,
this
.
onStart
,
null
,
null
));
this
.
ticks
.
on
(
'touchstart'
,
angular
.
bind
(
this
,
this
.
onMove
,
this
.
ticks
));
this
.
minH
.
on
(
'focus'
,
angular
.
bind
(
this
,
this
.
onPointerFocus
,
this
.
minH
,
'rzSliderModel'
))
if
(
this
.
range
)
{
this
.
maxH
.
on
(
'focus'
,
angular
.
bind
(
this
,
this
.
onPointerFocus
,
this
.
maxH
,
'rzSliderHigh'
));
}
},
/**
...
...
@@ -1156,10 +1161,6 @@
event
.
stopPropagation
();
event
.
preventDefault
();
if
(
this
.
tracking
!==
''
)
{
return
;
}
// We have to do this in case the HTML where the sliders are on
// have been animated into view.
this
.
calcViewDimensions
();
...
...
@@ -1210,6 +1211,49 @@
this
.
positionTrackingHandle
(
newValue
,
newOffset
);
},
onPointerFocus
:
function
(
pointer
,
ref
,
event
)
{
this
.
tracking
=
ref
;
pointer
.
one
(
'blur'
,
angular
.
bind
(
this
,
this
.
onPointerBlur
,
pointer
));
pointer
.
on
(
'keydown'
,
angular
.
bind
(
this
,
this
.
onKeyboardEvent
));
pointer
.
addClass
(
'rz-active'
);
},
onPointerBlur
:
function
(
pointer
,
event
)
{
this
.
tracking
=
''
;
pointer
.
off
(
'keydown'
);
pointer
.
removeClass
(
'rz-active'
);
},
onKeyboardEvent
:
function
(
event
)
{
var
keyCode
=
event
.
keyCode
||
event
.
which
,
keys
=
{
38
:
'UP'
,
40
:
'DOWN'
,
37
:
'LEFT'
,
39
:
'RIGHT'
},
actions
=
{
UP
:
5
,
DOWN
:
-
5
,
LEFT
:
-
1
,
RIGHT
:
1
},
key
=
keys
[
keyCode
],
action
=
actions
[
key
];
if
(
!
key
||
!
this
.
tracking
)
return
;
event
.
preventDefault
();
var
value
=
this
.
scope
[
this
.
tracking
],
newValue
=
this
.
roundStep
(
this
.
sanitizeValue
(
value
+
action
)),
newOffset
=
this
.
valueToOffset
(
newValue
);
var
switched
=
this
.
positionTrackingHandle
(
newValue
,
newOffset
);
if
(
switched
)
{
var
pointer
=
this
.
tracking
===
'rzSliderModel'
?
this
.
minH
:
this
.
maxH
;
pointer
[
0
].
focus
();
//to focus the correct pointer
}
},
/**
* onDragStart event handler
*
...
...
@@ -1302,10 +1346,12 @@
*/
positionTrackingHandle
:
function
(
newValue
,
newOffset
)
{
var
valueChanged
=
false
;
var
switched
=
false
;
if
(
this
.
range
)
{
/* This is to check if we need to switch the min and max handles*/
if
(
this
.
tracking
===
'rzSliderModel'
&&
newValue
>=
this
.
scope
.
rzSliderHigh
)
{
switched
=
true
;
this
.
scope
[
this
.
tracking
]
=
this
.
scope
.
rzSliderHigh
;
this
.
updateHandles
(
this
.
tracking
,
this
.
maxH
.
rzsp
);
this
.
tracking
=
'rzSliderHigh'
;
...
...
@@ -1313,6 +1359,7 @@
this
.
maxH
.
addClass
(
'rz-active'
);
valueChanged
=
true
;
}
else
if
(
this
.
tracking
===
'rzSliderHigh'
&&
newValue
<=
this
.
scope
.
rzSliderModel
)
{
switched
=
true
;
this
.
scope
[
this
.
tracking
]
=
this
.
scope
.
rzSliderModel
;
this
.
updateHandles
(
this
.
tracking
,
this
.
minH
.
rzsp
);
this
.
tracking
=
'rzSliderModel'
;
...
...
@@ -1332,6 +1379,7 @@
this
.
scope
.
$apply
();
this
.
callOnChange
();
}
return
switched
;
},
/**
...
...
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