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
703ad380
Commit
703ad380
authored
May 31, 2015
by
Rafal Zajac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address problems mentioned in #63
parent
0b2bf053
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
45 deletions
+82
-45
index.html
demo/index.html
+14
-0
rzslider.min.js
dist/rzslider.min.js
+1
-1
rzslider.js
rzslider.js
+67
-44
No files found.
demo/index.html
View file @
703ad380
...
...
@@ -17,6 +17,18 @@
<h1>
AngularJS Touch Slider
</h1>
</header>
<article>
<h2>
Min/max slider example
</h2>
Value:
<pre>
{{ slider_data | json }}
</pre>
<rzslider
rz-slider-floor=
"0.5"
rz-slider-ceil=
"10.5"
rz-slider-step=
"0.1"
rz-slider-precision=
"1"
rz-slider-model=
"slider_data.value"
></rzslider>
</article>
<article>
<h2>
Min/max slider example
</h2>
Value:
<pre>
{{ priceSlider | json }}
</pre>
...
...
@@ -99,6 +111,8 @@
{
return
alphabetArray
[
value
].
toUpperCase
();
};
$scope
.
slider_data
=
{
value
:
1
};
});
</script>
...
...
dist/rzslider.min.js
View file @
703ad380
This diff is collapsed.
Click to expand it.
rzslider.js
View file @
703ad380
...
...
@@ -10,7 +10,7 @@
*/
/*jslint unparam: true */
/*global angular: false */
/*global angular: false
, console: false
*/
angular
.
module
(
'rzModule'
,
[])
...
...
@@ -208,7 +208,12 @@ function throttle(func, wait, options) {
*/
this
.
customTrFn
=
this
.
scope
.
rzSliderTranslate
()
||
function
(
value
)
{
return
String
(
value
);
};
this
.
unbinders
=
[];
/**
* Array of de-registration functions to call on $destroy
*
* @type {Array.<Function>}
*/
this
.
deRegFuncs
=
[];
// Slider DOM elements wrapped in jqLite
this
.
fullBar
=
null
;
// The whole slider bar
...
...
@@ -235,7 +240,9 @@ function throttle(func, wait, options) {
*/
init
:
function
()
{
var
self
=
this
;
var
thrLow
,
thrHigh
,
unRegFn
,
calcDimFn
=
angular
.
bind
(
this
,
this
.
calcViewDimensions
),
self
=
this
;
this
.
initElemHandles
();
this
.
calcViewDimensions
();
...
...
@@ -253,16 +260,17 @@ function throttle(func, wait, options) {
});
// Recalculate slider view dimensions
this
.
scope
.
$on
(
'reCalcViewDimensions'
,
angular
.
bind
(
this
,
this
.
calcViewDimensions
));
unRegFn
=
this
.
scope
.
$on
(
'reCalcViewDimensions'
,
calcDimFn
);
this
.
deRegFuncs
.
push
(
unRegFn
);
// Recalculate stuff if view port dimensions have changed
angular
.
element
(
$window
).
on
(
'resize'
,
angular
.
bind
(
this
,
this
.
calcViewDimensions
)
);
angular
.
element
(
$window
).
on
(
'resize'
,
calcDimFn
);
this
.
initHasRun
=
true
;
// Watch for changes to the model
var
thrLow
=
throttle
(
function
()
thrLow
=
throttle
(
function
()
{
self
.
setMinAndMax
();
self
.
updateLowHandle
(
self
.
valueToOffset
(
self
.
scope
.
rzSliderModel
));
...
...
@@ -275,7 +283,7 @@ function throttle(func, wait, options) {
},
350
,
{
leading
:
false
});
var
thrHigh
=
throttle
(
function
()
thrHigh
=
throttle
(
function
()
{
self
.
setMinAndMax
();
self
.
updateHighHandle
(
self
.
valueToOffset
(
self
.
scope
.
rzSliderHigh
));
...
...
@@ -293,44 +301,40 @@ function throttle(func, wait, options) {
// Watchers
this
.
unbinders
.
push
(
this
.
scope
.
$watch
(
'rzSliderModel'
,
function
(
newValue
,
oldValue
)
unRegFn
=
this
.
scope
.
$watch
(
'rzSliderModel'
,
function
(
newValue
,
oldValue
)
{
if
(
newValue
===
oldValue
)
{
return
;
}
thrLow
();
}));
});
this
.
deRegFuncs
.
push
(
unRegFn
);
this
.
unbinders
.
push
(
this
.
scope
.
$watch
(
'rzSliderHigh'
,
function
(
newValue
,
oldValue
)
unRegFn
=
this
.
scope
.
$watch
(
'rzSliderHigh'
,
function
(
newValue
,
oldValue
)
{
if
(
newValue
===
oldValue
)
{
return
;
}
thrHigh
();
}));
});
this
.
deRegFuncs
.
push
(
unRegFn
);
this
.
unbinders
.
push
(
this
.
scope
.
$watch
(
'rzSliderFloor'
,
function
(
newValue
,
oldValue
)
this
.
scope
.
$watch
(
'rzSliderFloor'
,
function
(
newValue
,
oldValue
)
{
if
(
newValue
===
oldValue
)
{
return
;
}
self
.
resetSlider
();
}));
});
this
.
deRegFuncs
.
push
(
unRegFn
);
this
.
unbinders
.
push
(
this
.
scope
.
$watch
(
'rzSliderCeil'
,
function
(
newValue
,
oldValue
)
unRegFn
=
this
.
scope
.
$watch
(
'rzSliderCeil'
,
function
(
newValue
,
oldValue
)
{
if
(
newValue
===
oldValue
)
{
return
;
}
self
.
resetSlider
();
}));
$document
.
on
(
'$destroy'
,
function
()
{
self
.
minH
.
off
(
'.rzslider'
);
self
.
maxH
.
off
(
'.rzslider'
);
$document
.
off
(
'.rzslider'
);
angular
.
element
(
$window
).
off
(
'.rzslider'
);
});
this
.
deRegFuncs
.
push
(
unRegFn
);
this
.
scope
.
$on
(
'$destroy'
,
function
()
{
self
.
unbinders
.
map
(
function
(
unbind
)
{
unbind
(
);
});
self
.
minH
.
off
();
self
.
maxH
.
off
();
angular
.
element
(
$window
).
off
(
calcDimFn
);
self
.
deRegFuncs
.
map
(
function
(
unbind
)
{
unbind
();
});
});
},
...
...
@@ -564,6 +568,7 @@ function throttle(func, wait, options) {
*/
updateHandles
:
function
(
which
,
newOffset
)
{
console
.
log
(
which
,
newOffset
);
// TODO: remove this!
if
(
which
===
'rzSliderModel'
)
{
this
.
updateLowHandle
(
newOffset
);
...
...
@@ -604,7 +609,7 @@ function throttle(func, wait, options) {
updateLowHandle
:
function
(
newOffset
)
{
var
delta
=
Math
.
abs
(
this
.
minH
.
rzsl
-
newOffset
);
if
(
delta
===
0
||
delta
===
1
)
{
return
;
}
if
(
delta
<=
0
&&
delta
<
1
)
{
return
;
}
this
.
setLeft
(
this
.
minH
,
newOffset
);
this
.
translateFn
(
this
.
scope
.
rzSliderModel
,
this
.
minLab
);
...
...
@@ -858,6 +863,9 @@ function throttle(func, wait, options) {
*/
onStart
:
function
(
pointer
,
ref
,
event
)
{
var
ehMove
,
ehEnd
,
eventNames
=
this
.
getEventNames
(
event
);
event
.
stopPropagation
();
event
.
preventDefault
();
...
...
@@ -870,16 +878,11 @@ function throttle(func, wait, options) {
pointer
.
addClass
(
'rz-active'
);
if
(
event
.
touches
||
(
event
.
originalEvent
!==
undefined
&&
event
.
originalEvent
.
touches
))
{
$document
.
on
(
'touchmove'
,
angular
.
bind
(
this
,
this
.
onMove
,
pointer
));
$document
.
one
(
'touchend'
,
angular
.
bind
(
this
,
this
.
onEnd
));
}
else
{
$document
.
on
(
'mousemove'
,
angular
.
bind
(
this
,
this
.
onMove
,
pointer
));
$document
.
one
(
'mouseup'
,
angular
.
bind
(
this
,
this
.
onEnd
));
}
ehMove
=
angular
.
bind
(
this
,
this
.
onMove
,
pointer
);
ehEnd
=
angular
.
bind
(
this
,
this
.
onEnd
,
ehMove
);
$document
.
on
(
eventNames
.
moveEvent
,
ehMove
);
$document
.
one
(
eventNames
.
endEvent
,
ehEnd
);
},
/**
...
...
@@ -967,26 +970,46 @@ function throttle(func, wait, options) {
/**
* onEnd event handler
*
* @param {Event} event The event
* @param {Event} event The event
* @param {Function} ehMove The the bound move event handler
* @returns {undefined}
*/
onEnd
:
function
(
event
)
onEnd
:
function
(
e
hMove
,
e
vent
)
{
var
moveEventName
=
this
.
getEventNames
(
event
).
moveEvent
;
this
.
minH
.
removeClass
(
'rz-active'
);
this
.
maxH
.
removeClass
(
'rz-active'
);
$document
.
off
(
moveEventName
,
ehMove
);
this
.
scope
.
$emit
(
'slideEnded'
);
this
.
tracking
=
''
;
},
/**
* Get event names for move and event end
*
* @param {Event} event The event
*
* @return {{moveEvent: string, endEvent: string}}
*/
getEventNames
:
function
(
event
)
{
var
eventNames
=
{
moveEvent
:
''
,
endEvent
:
''
};
if
(
event
.
touches
||
(
event
.
originalEvent
!==
undefined
&&
event
.
originalEvent
.
touches
))
{
$document
.
off
(
'touchmove'
);
eventNames
.
moveEvent
=
'touchmove'
;
eventNames
.
endEvent
=
'touchend'
;
}
else
{
$document
.
off
(
'mousemove'
);
eventNames
.
moveEvent
=
'mousemove'
;
eventNames
.
endEvent
=
'mouseup'
;
}
this
.
scope
.
$emit
(
'slideEnded'
);
this
.
tracking
=
''
;
return
eventNames
;
}
};
...
...
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