Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

fix(slider): adds padding inside of slider to fit the thumb #1391

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions src/components/slider/slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,22 @@ function SliderDirective($$rAF, $window, $mdAria, $mdUtil, $mdConstant, $mdThemi
scope: {},
require: '?ngModel',
template:
'<div class="md-track-container">' +
'<div class="md-track"></div>' +
'<div class="md-track md-track-fill"></div>' +
'<div class="md-track-ticks"></div>' +
'</div>' +
'<div class="md-thumb-container">' +
'<div class="md-thumb"></div>' +
'<div class="md-focus-thumb"></div>' +
'<div class="md-focus-ring"></div>' +
'<div class="md-sign">' +
'<span class="md-thumb-text"></span>' +
'</div>' +
'<div class="md-disabled-thumb"></div>' +
'</div>',
'<div class="md-slider-wrapper">\
<div class="md-track-container">\
<div class="md-track"></div>\
<div class="md-track md-track-fill"></div>\
<div class="md-track-ticks"></div>\
</div>\
<div class="md-thumb-container">\
<div class="md-thumb"></div>\
<div class="md-focus-thumb"></div>\
<div class="md-focus-ring"></div>\
<div class="md-sign">\
<span class="md-thumb-text"></span>\
</div>\
<div class="md-disabled-thumb"></div>\
</div>\
</div>',
compile: compile
};

Expand Down Expand Up @@ -100,7 +102,7 @@ function SliderDirective($$rAF, $window, $mdAria, $mdUtil, $mdConstant, $mdThemi
};

var isDisabledParsed = attr.ngDisabled && $parse(attr.ngDisabled);
var isDisabledGetter = isDisabledParsed ?
var isDisabledGetter = isDisabledParsed ?
function() { return isDisabledParsed(scope.$parent); } :
angular.noop;
var thumb = angular.element(element[0].querySelector('.md-thumb'));
Expand Down Expand Up @@ -280,8 +282,8 @@ function SliderDirective($$rAF, $window, $mdAria, $mdUtil, $mdConstant, $mdThemi
function setSliderPercent(percent) {
activeTrack.css('width', (percent * 100) + '%');
thumbContainer.css(
$mdConstant.CSS.TRANSFORM,
'translate3d(' + (percent * 100) + '%,0,0)'
'left',
(percent * 100) + '%'
);
element.toggleClass('md-min', percent === 0);
}
Expand Down Expand Up @@ -316,6 +318,7 @@ function SliderDirective($$rAF, $window, $mdAria, $mdUtil, $mdConstant, $mdThemi
var closestVal = minMaxValidator( stepValidator(exactVal) );
scope.$apply(function() {
setModelValue(closestVal);
ngModelRender();
});
}
function onDragStart(ev) {
Expand Down
12 changes: 8 additions & 4 deletions src/components/slider/slider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ md-slider {
display: block;
margin-left: 4px;
margin-right: 4px;
padding: 0;

.md-slider-wrapper {
position: relative;
}

/**
* Track
Expand Down Expand Up @@ -84,10 +89,9 @@ md-slider {
.md-thumb-container {
position: absolute;
left: 0;
top: 0;
right: 0;
transform: translate3d(0,0,0);
transition: transform 0.1s linear;
top: 50%;
transform: translate3d(-50%,-50%,0);
transition: left 0.1s linear;
}
.md-thumb {
z-index: 1;
Expand Down