Last active
March 18, 2016 04:36
-
-
Save EdwardCTaylor/31e26e2c804eec78e97e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.range-slider-container { | |
position:relative; | |
width:100%; | |
height:100px; | |
} | |
.range-slider-left { | |
position:absolute; | |
top:0; | |
width:100%; | |
md-slider .md-track-container .md-track.md-track-fill { | |
background-color:rgb(132,132,132); | |
} | |
} | |
.range-slider-right { | |
position:absolute; | |
top:0; | |
right:0px; | |
} | |
// Overwrite specific to range adaptation | |
.range-slider-right md-slider .md-thumb-container { | |
transition: -webkit-transform 0s linear; | |
transition: transform 0s linear; | |
} | |
.range-slider-left md-slider.md-default-theme .md-track.md-track-fill { | |
background-color:rgba(0,0,0,0.26) !important; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('directives.rangeSlider',['material.components.slider']) | |
.directive('rangeSlider', function ($compile) { | |
return { | |
restrict: "E", | |
replace: true, | |
scope: { | |
max:'=', | |
min:'=', | |
minGap: '=', | |
step:'=', | |
lowerValue: "=lowerValue", | |
upperValue: "=upperValue" | |
}, | |
controller: function($scope) { | |
$scope.lowerMax = $scope.max - $scope.step; | |
$scope.upperMin = $scope.lowerValue + $scope.step; | |
$scope.lowerValue = $scope.min; | |
$scope.upperValue = $scope.max; | |
$scope.$watch('lowerValue',function(){ | |
$scope.upperMin = $scope.lowerValue + $scope.step; | |
$scope.upperWidth = ((($scope.max-($scope.lowerValue + $scope.step))/$scope.max) * 100) + "%"; | |
if($scope.lowerValue > ($scope.upperValue - $scope.minGap) && $scope.upperValue < $scope.max) { | |
$scope.upperValue = $scope.lowerValue + $scope.minGap; | |
} | |
}) | |
}, | |
templateUrl:'app/common/sliders/range-slider.tpl.html', | |
link: function (scope, element, attrs) { | |
} | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class='range-slider-container'> | |
<div class='range-slider-left'> | |
<md-slider aria-label="upperValue" ng-model="lowerValue" min='{{min}}' max='{{lowerMax}}'></md-slider> | |
</div> | |
<div class='range-slider-right' ng-style="{width: upperWidth}"> | |
<md-slider aria-label="upperValue" ng-model="upperValue" min="{{upperMin}}" max="{{max}}"></md-slider> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment