@@ -95,9 +95,9 @@ module.exports = function(gd) {
95
95
opts . _height = ( fullLayout . height - margin . b - margin . t ) * opts . thickness ;
96
96
opts . _offsetShift = Math . floor ( opts . borderwidth / 2 ) ;
97
97
98
- var x = margin . l + ( graphSize . w * domain [ 0 ] ) ;
98
+ var x = Math . round ( margin . l + ( graphSize . w * domain [ 0 ] ) ) ;
99
99
100
- var y = (
100
+ var y = Math . round (
101
101
margin . t + graphSize . h * ( 1 - oppDomain [ 0 ] ) +
102
102
tickHeight +
103
103
opts . _offsetShift + constants . extraPad
@@ -252,11 +252,16 @@ function setDataRange(rangeSlider, gd, axisOpts, opts) {
252
252
}
253
253
254
254
function setPixelRange ( rangeSlider , gd , axisOpts , opts ) {
255
+ var hw2 = constants . handleWidth / 2 ;
255
256
256
257
function clamp ( v ) {
257
258
return Lib . constrain ( v , 0 , opts . _width ) ;
258
259
}
259
260
261
+ function clampHandle ( v ) {
262
+ return Lib . constrain ( v , - hw2 , opts . _width + hw2 ) ;
263
+ }
264
+
260
265
var pixelMin = clamp ( opts . d2p ( axisOpts . _rl [ 0 ] ) ) ,
261
266
pixelMax = clamp ( opts . d2p ( axisOpts . _rl [ 1 ] ) ) ;
262
267
@@ -271,11 +276,17 @@ function setPixelRange(rangeSlider, gd, axisOpts, opts) {
271
276
. attr ( 'x' , pixelMax )
272
277
. attr ( 'width' , opts . _width - pixelMax ) ;
273
278
279
+ // ..
280
+ var offset = 0.5 ;
281
+
282
+ var xMin = Math . round ( clampHandle ( pixelMin - hw2 ) ) - offset ,
283
+ xMax = Math . round ( clampHandle ( pixelMax - hw2 ) ) + offset ;
284
+
274
285
rangeSlider . select ( 'g.' + constants . grabberMinClassName )
275
- . attr ( 'transform' , 'translate(' + ( pixelMin - constants . handleWidth - 1 ) + ',0 )' ) ;
286
+ . attr ( 'transform' , 'translate(' + xMin + ',' + offset + ')' ) ;
276
287
277
288
rangeSlider . select ( 'g.' + constants . grabberMaxClassName )
278
- . attr ( 'transform' , 'translate(' + pixelMax + ',0 )' ) ;
289
+ . attr ( 'transform' , 'translate(' + xMax + ',' + offset + ' )') ;
279
290
}
280
291
281
292
function drawBg ( rangeSlider , gd , axisOpts , opts ) {
@@ -295,14 +306,15 @@ function drawBg(rangeSlider, gd, axisOpts, opts) {
295
306
opts . borderwidth - 1 ;
296
307
297
308
var offsetShift = - opts . _offsetShift ;
309
+ var lw = Drawing . crispRound ( gd , opts . borderwidth ) ;
298
310
299
311
bg . attr ( {
300
312
width : opts . _width + borderCorrect ,
301
313
height : opts . _height + borderCorrect ,
302
314
transform : 'translate(' + offsetShift + ',' + offsetShift + ')' ,
303
315
fill : opts . bgcolor ,
304
316
stroke : opts . bordercolor ,
305
- 'stroke-width' : opts . borderwidth ,
317
+ 'stroke-width' : lw
306
318
} ) ;
307
319
}
308
320
@@ -415,7 +427,8 @@ function drawMasks(rangeSlider, gd, axisOpts, opts) {
415
427
416
428
maskMin . enter ( ) . append ( 'rect' )
417
429
. classed ( constants . maskMinClassName , true )
418
- . attr ( { x : 0 , y : 0 } ) ;
430
+ . attr ( { x : 0 , y : 0 } )
431
+ . attr ( 'shape-rendering' , 'crispEdges' ) ;
419
432
420
433
maskMin
421
434
. attr ( 'height' , opts . _height )
@@ -426,7 +439,8 @@ function drawMasks(rangeSlider, gd, axisOpts, opts) {
426
439
427
440
maskMax . enter ( ) . append ( 'rect' )
428
441
. classed ( constants . maskMaxClassName , true )
429
- . attr ( 'y' , 0 ) ;
442
+ . attr ( 'y' , 0 )
443
+ . attr ( 'shape-rendering' , 'crispEdges' ) ;
430
444
431
445
maskMax
432
446
. attr ( 'height' , opts . _height )
@@ -442,7 +456,8 @@ function drawSlideBox(rangeSlider, gd, axisOpts, opts) {
442
456
slideBox . enter ( ) . append ( 'rect' )
443
457
. classed ( constants . slideBoxClassName , true )
444
458
. attr ( 'y' , 0 )
445
- . attr ( 'cursor' , constants . slideBoxCursor ) ;
459
+ . attr ( 'cursor' , constants . slideBoxCursor )
460
+ . attr ( 'shape-rendering' , 'crispEdges' ) ;
446
461
447
462
slideBox . attr ( {
448
463
height : opts . _height ,
@@ -470,14 +485,15 @@ function drawGrabbers(rangeSlider, gd, axisOpts, opts) {
470
485
x : 0 ,
471
486
width : constants . handleWidth ,
472
487
rx : constants . handleRadius ,
473
- fill : constants . handleFill ,
474
- stroke : constants . handleStroke ,
488
+ fill : Color . background ,
489
+ stroke : Color . defaultLine ,
490
+ 'stroke-width' : constants . handleStrokeWidth ,
475
491
'shape-rendering' : 'crispEdges'
476
492
} ;
477
493
478
494
var handleDynamicAttrs = {
479
- y : opts . _height / 4 ,
480
- height : opts . _height / 2 ,
495
+ y : Math . round ( opts . _height / 4 ) ,
496
+ height : Math . round ( opts . _height / 2 ) ,
481
497
} ;
482
498
483
499
var handleMin = grabberMin . selectAll ( 'rect.' + constants . handleMinClassName )
@@ -500,6 +516,7 @@ function drawGrabbers(rangeSlider, gd, axisOpts, opts) {
500
516
501
517
var grabAreaFixAttrs = {
502
518
width : constants . grabAreaWidth ,
519
+ x : 0 ,
503
520
y : 0 ,
504
521
fill : constants . grabAreaFill ,
505
522
cursor : constants . grabAreaCursor
@@ -510,20 +527,14 @@ function drawGrabbers(rangeSlider, gd, axisOpts, opts) {
510
527
grabAreaMin . enter ( ) . append ( 'rect' )
511
528
. classed ( constants . grabAreaMinClassName , true )
512
529
. attr ( grabAreaFixAttrs ) ;
513
- grabAreaMin . attr ( {
514
- x : constants . grabAreaMinOffset ,
515
- height : opts . _height
516
- } ) ;
530
+ grabAreaMin . attr ( 'height' , opts . _height ) ;
517
531
518
532
var grabAreaMax = grabberMax . selectAll ( 'rect.' + constants . grabAreaMaxClassName )
519
533
. data ( [ 0 ] ) ;
520
534
grabAreaMax . enter ( ) . append ( 'rect' )
521
535
. classed ( constants . grabAreaMaxClassName , true )
522
536
. attr ( grabAreaFixAttrs ) ;
523
- grabAreaMax . attr ( {
524
- x : constants . grabAreaMaxOffset ,
525
- height : opts . _height
526
- } ) ;
537
+ grabAreaMax . attr ( 'height' , opts . _height ) ;
527
538
}
528
539
529
540
function clearPushMargins ( gd ) {
0 commit comments