Skip to content

Commit 46cca0a

Browse files
committed
Handle vertical + reverse case
1 parent bdbd1e8 commit 46cca0a

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

demo/demo.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,12 @@ app.controller('MainCtrl', function($scope, $rootScope, $timeout, $uibModal) {
426426
options: {
427427
floor: 0,
428428
ceil: 10,
429-
vertical: true
429+
vertical: true,
430+
showSelectionBarEnd: true,
431+
selectionBarGradient: {
432+
from: 'white',
433+
to: '#0db9f0'
434+
}
430435
}
431436
};
432437
$scope.verticalSlider2 = {

dist/rzslider.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,12 +1272,12 @@
12721272
} else if (this.options.selectionBarGradient) {
12731273
var offset = this.options.showSelectionBarFromValue !== null ? this.valueToPosition(this.options.showSelectionBarFromValue) : 0,
12741274
reversed = offset - position > 0 ^ isSelectionBarFromRight,
1275-
direction = this.options.vertical ? 'top' : (reversed ? 'left' : 'right');
1275+
direction = this.options.vertical ? (reversed ? 'bottom' : 'top') : (reversed ? 'left' : 'right');
12761276
this.scope.barStyle = {
12771277
backgroundImage: 'linear-gradient(to ' + direction + ', ' + this.options.selectionBarGradient.from + ' 0%,' + this.options.selectionBarGradient.to + ' 100%)'
12781278
};
12791279
if (this.options.vertical) {
1280-
this.scope.barStyle.backgroundPosition = 'center ' + (offset + dimension + position + (reversed ? this.handleHalfDim : 0)) + 'px';
1280+
this.scope.barStyle.backgroundPosition = 'center ' + (offset + dimension + position + (reversed ? -this.handleHalfDim : 0)) + 'px';
12811281
this.scope.barStyle.backgroundSize = '100% ' + (this.barDimension - this.handleHalfDim) + 'px';
12821282
} else {
12831283
this.scope.barStyle.backgroundPosition = (offset - position + (reversed ? this.handleHalfDim : 0)) + 'px center';

dist/rzslider.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/rzslider.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,12 +1276,12 @@
12761276
} else if (this.options.selectionBarGradient) {
12771277
var offset = this.options.showSelectionBarFromValue !== null ? this.valueToPosition(this.options.showSelectionBarFromValue) : 0,
12781278
reversed = offset - position > 0 ^ isSelectionBarFromRight,
1279-
direction = this.options.vertical ? 'top' : (reversed ? 'left' : 'right');
1279+
direction = this.options.vertical ? (reversed ? 'bottom' : 'top') : (reversed ? 'left' : 'right');
12801280
this.scope.barStyle = {
12811281
backgroundImage: 'linear-gradient(to ' + direction + ', ' + this.options.selectionBarGradient.from + ' 0%,' + this.options.selectionBarGradient.to + ' 100%)'
12821282
};
12831283
if (this.options.vertical) {
1284-
this.scope.barStyle.backgroundPosition = 'center ' + (offset + dimension + position + (reversed ? this.handleHalfDim : 0)) + 'px';
1284+
this.scope.barStyle.backgroundPosition = 'center ' + (offset + dimension + position + (reversed ? -this.handleHalfDim : 0)) + 'px';
12851285
this.scope.barStyle.backgroundSize = '100% ' + (this.barDimension - this.handleHalfDim) + 'px';
12861286
} else {
12871287
this.scope.barStyle.backgroundPosition = (offset - position + (reversed ? this.handleHalfDim : 0)) + 'px center';

0 commit comments

Comments
 (0)