Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
angular-material
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bower
angular-material
Commits
a31d6613
Commit
a31d6613
authored
8 years ago
by
Krzysztof Bąk
Browse files
Options
Downloads
Patches
Plain Diff
Improving slider
parent
0ea28bc7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
angular-material.js
+35208
-0
35208 additions, 0 deletions
angular-material.js
src/components/slider/slider.js
+7
-2
7 additions, 2 deletions
src/components/slider/slider.js
with
35215 additions
and
2 deletions
angular-material.js
0 → 100644
+
35208
−
0
View file @
a31d6613
This diff is collapsed.
Click to expand it.
src/components/slider/slider.js
+
7
−
2
View file @
a31d6613
...
...
@@ -218,6 +218,7 @@ function SliderDirective($$rAF, $window, $mdAria, $mdUtil, $mdConstant, $mdThemi
angular
.
isDefined
(
attr
.
max
)
?
attr
.
$observe
(
'
max
'
,
updateMax
)
:
updateMax
(
100
);
angular
.
isDefined
(
attr
.
step
)?
attr
.
$observe
(
'
step
'
,
updateStep
)
:
updateStep
(
1
);
angular
.
isDefined
(
attr
.
round
)?
attr
.
$observe
(
'
round
'
,
updateRound
)
:
updateRound
(
DEFAULT_ROUND
);
angular
.
isDefined
(
attr
.
decimals
)
?
attr
.
$observe
(
'
decimals
'
,
updateDecimals
)
:
updateDecimals
(
0
);
// We have to manually stop the $watch on ngDisabled because it exists
// on the parent scope, and won't be automatically destroyed when
...
...
@@ -268,6 +269,7 @@ function SliderDirective($$rAF, $window, $mdAria, $mdUtil, $mdConstant, $mdThemi
var
max
;
var
step
;
var
round
;
var
decimals
;
function
updateMin
(
value
)
{
min
=
parseFloat
(
value
);
element
.
attr
(
'
aria-valuemin
'
,
value
);
...
...
@@ -288,6 +290,9 @@ function SliderDirective($$rAF, $window, $mdAria, $mdUtil, $mdConstant, $mdThemi
function
updateAriaDisabled
()
{
element
.
attr
(
'
aria-disabled
'
,
!!
isDisabled
());
}
function
updateDecimals
(
value
)
{
decimals
=
parseInt
(
value
);
}
// Draw the ticks with canvas.
// The alternative to drawing ticks with canvas is to draw one element for each tick,
...
...
@@ -421,7 +426,7 @@ function SliderDirective($$rAF, $window, $mdAria, $mdUtil, $mdConstant, $mdThemi
scope
.
modelValue
=
ngModelCtrl
.
$viewValue
;
element
.
attr
(
'
aria-valuenow
'
,
ngModelCtrl
.
$viewValue
);
setSliderPercent
(
percent
);
thumbText
.
text
(
ngModelCtrl
.
$viewValue
);
thumbText
.
text
(
ngModelCtrl
.
$viewValue
.
toFixed
(
decimals
)
);
}
function
minMaxValidator
(
value
,
minValue
,
maxValue
)
{
...
...
@@ -548,7 +553,7 @@ function SliderDirective($$rAF, $window, $mdAria, $mdUtil, $mdConstant, $mdThemi
var
exactVal
=
percentToValue
(
positionToPercent
(
x
));
var
closestVal
=
minMaxValidator
(
stepValidator
(
exactVal
)
);
setSliderPercent
(
positionToPercent
(
x
)
);
thumbText
.
text
(
closestVal
);
thumbText
.
text
(
closestVal
.
toFixed
(
decimals
)
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment