-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Slider component #986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slider component #986
Changes from 1 commit
f5bccd5
83483fd
f69a328
82ea558
ca5f9f5
c6a3e11
5b74652
e13e0ee
8fe1842
05ac586
4604341
8558be8
c673afe
304174a
fce36fa
52b4a2a
b161d55
8d7c40d
30b5f2d
19442d9
ecb7e87
9c0f9ac
2a6f987
5bd6bdd
4520a48
88d6728
6da5b0f
1cad8a4
4a9edd0
6cb6d42
4775a47
a08f084
5816c24
2cfa81b
1d52b51
892583d
5015710
582c643
70610ec
f25127c
4b608ee
6c9034d
21e2f99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,9 +11,9 @@ | |
var Lib = require('../../lib'); | ||
|
||
var attributes = require('./attributes'); | ||
var contants = require('./constants'); | ||
var constants = require('./constants'); | ||
|
||
var name = contants.name; | ||
var name = constants.name; | ||
var stepAttrs = attributes.steps; | ||
|
||
|
||
|
@@ -73,12 +73,17 @@ function sliderDefaults(sliderIn, sliderOut, layoutOut) { | |
coerce('transition.duration'); | ||
coerce('transition.easing'); | ||
|
||
Lib.coerceFont(coerce, 'font', layoutOut.font); | ||
Lib.coerceFont(coerce, 'currentvalue.font', layoutOut.font); | ||
|
||
coerce('bgcolor', layoutOut.paper_bgcolor); | ||
coerce('bgcolor'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see the default There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No good reason except that it didn't actually seem like a desirable default since that would just make the slider transparent-looking instead of filled by default. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To elaborate slightly, this attribute wasn't used before. Until today it was a hard-coded constant. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I agree 100%. I just wanted to make sure the above patch was not a typo 👍 |
||
coerce('activebgcolor'); | ||
coerce('bordercolor'); | ||
coerce('borderwidth'); | ||
coerce('ticklen'); | ||
coerce('tickwidth'); | ||
coerce('tickcolor'); | ||
coerce('minorticklen'); | ||
|
||
Lib.coerceFont(coerce, 'font', layoutOut.font); | ||
Lib.coerceFont(coerce, 'currentvalue.font', sliderOut.font); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similarly here, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✅ |
||
} | ||
|
||
function stepsDefaults(sliderIn, sliderOut) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,7 +177,7 @@ function findDimensions(gd, sliderOpts) { | |
sliderOpts.labelStride = Math.max(1, Math.ceil(computedSpacePerLabel / availableSpacePerLabel)); | ||
sliderOpts.labelHeight = labelHeight; | ||
|
||
sliderOpts.height = sliderOpts.currentValueTotalHeight + constants.tickOffset + constants.tickLength + constants.labelOffset + sliderOpts.labelHeight + sliderOpts.pad.t + sliderOpts.pad.b; | ||
sliderOpts.height = sliderOpts.currentValueTotalHeight + constants.tickOffset + sliderOpts.ticklen + constants.labelOffset + sliderOpts.labelHeight + sliderOpts.pad.t + sliderOpts.pad.b; | ||
|
||
var xanchor = 'left'; | ||
if(anchorUtils.isRightAnchor(sliderOpts)) { | ||
|
@@ -292,9 +292,9 @@ function drawGrip(sliderGroup, gd, sliderOpts) { | |
rx: constants.gripRadius, | ||
ry: constants.gripRadius, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
}) | ||
.call(Color.stroke, constants.gripBorderColor) | ||
.call(Color.fill, constants.gripBgColor) | ||
.style('stroke-width', constants.gripBorderWidth + 'px'); | ||
.call(Color.stroke, sliderOpts.bordercolor) | ||
.call(Color.fill, sliderOpts.bgcolor) | ||
.style('stroke-width', sliderOpts.borderwidth + 'px'); | ||
} | ||
|
||
function drawLabel(item, data, sliderOpts) { | ||
|
@@ -335,7 +335,7 @@ function drawLabelGroup(sliderGroup, sliderOpts) { | |
|
||
Lib.setTranslate(item, | ||
normalizedValueToPosition(sliderOpts, d.fraction), | ||
constants.tickOffset + constants.tickLength + sliderOpts.labelHeight + constants.labelOffset + sliderOpts.currentValueTotalHeight | ||
constants.tickOffset + sliderOpts.ticklen + sliderOpts.labelHeight + constants.labelOffset + sliderOpts.currentValueTotalHeight | ||
); | ||
}); | ||
|
||
|
@@ -398,7 +398,7 @@ function attachGripEvents(item, gd, sliderGroup, sliderOpts) { | |
|
||
d3.event.stopPropagation(); | ||
d3.event.preventDefault(); | ||
grip.call(Color.fill, constants.gripBgActiveColor); | ||
grip.call(Color.fill, sliderOpts.activebgcolor); | ||
|
||
var normalizedPosition = positionToNormalizedValue(sliderOpts, d3.mouse(node)[0]); | ||
handleInput(gd, sliderGroup, sliderOpts, normalizedPosition, true); | ||
|
@@ -409,7 +409,7 @@ function attachGripEvents(item, gd, sliderGroup, sliderOpts) { | |
}); | ||
|
||
$gd.on('mouseup', function() { | ||
grip.call(Color.fill, constants.gripBgColor); | ||
grip.call(Color.fill, sliderOpts.bgcolor); | ||
$gd.on('mouseup', null); | ||
$gd.on('mousemove', null); | ||
}); | ||
|
@@ -426,7 +426,7 @@ function drawTicks(sliderGroup, sliderOpts) { | |
tick.exit().remove(); | ||
|
||
tick.attr({ | ||
width: constants.tickWidth, | ||
width: sliderOpts.tickwidth + 'px', | ||
'shape-rendering': 'crispEdges' | ||
}); | ||
|
||
|
@@ -435,11 +435,11 @@ function drawTicks(sliderGroup, sliderOpts) { | |
var item = d3.select(this); | ||
|
||
item | ||
.attr({height: isMajor ? constants.tickLength : constants.minorTickLength}) | ||
.call(Color.fill, isMajor ? constants.tickColor : constants.minorTickColor); | ||
.attr({height: isMajor ? sliderOpts.ticklen : sliderOpts.minorticklen}) | ||
.call(Color.fill, isMajor ? sliderOpts.tickcolor : sliderOpts.tickcolor); | ||
|
||
Lib.setTranslate(item, | ||
normalizedValueToPosition(sliderOpts, i / (sliderOpts.steps.length - 1)) - 0.5 * constants.tickWidth, | ||
normalizedValueToPosition(sliderOpts, i / (sliderOpts.steps.length - 1)) - 0.5 * sliderOpts.tickwidth, | ||
(isMajor ? constants.tickOffset : constants.minorTickOffset) + sliderOpts.currentValueTotalHeight | ||
); | ||
}); | ||
|
@@ -498,9 +498,9 @@ function drawTouchRect(sliderGroup, gd, sliderOpts) { | |
|
||
rect.attr({ | ||
width: sliderOpts.inputAreaLength, | ||
height: Math.max(sliderOpts.inputAreaWidth, constants.tickOffset + constants.tickLength + sliderOpts.labelHeight) | ||
height: Math.max(sliderOpts.inputAreaWidth, constants.tickOffset + sliderOpts.ticklen + sliderOpts.labelHeight) | ||
}) | ||
.call(Color.fill, constants.gripBgColor) | ||
.call(Color.fill, sliderOpts.bgcolor) | ||
.attr('opacity', 0); | ||
|
||
Lib.setTranslate(rect, 0, sliderOpts.currentValueTotalHeight); | ||
|
@@ -522,9 +522,9 @@ function drawRail(sliderGroup, sliderOpts) { | |
ry: constants.railRadius, | ||
'shape-rendering': 'crispEdges' | ||
}) | ||
.call(Color.stroke, constants.railBorderColor) | ||
.call(Color.fill, constants.railBgColor) | ||
.style('stroke-width', '1px'); | ||
.call(Color.stroke, sliderOpts.bordercolor) | ||
.call(Color.fill, sliderOpts.bgcolor) | ||
.style('stroke-width', sliderOpts.borderwidth + 'px'); | ||
|
||
Lib.setTranslate(rect, | ||
constants.railInset, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice