Skip to content

Range slider second iteration (part 1) #962

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

Merged
merged 14 commits into from
Oct 6, 2016
Merged
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
2 changes: 2 additions & 0 deletions src/components/dragelement/index.js
Original file line number Diff line number Diff line change
@@ -177,6 +177,8 @@ function coverSlip() {
return cover;
}

dragElement.coverSlip = coverSlip;

function finishDrag(gd) {
gd._dragging = false;
if(gd._replotPending) Plotly.plot(gd);
51 changes: 51 additions & 0 deletions src/components/rangeslider/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Copyright 2012-2016, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

module.exports = {

// attribute container name
name: 'rangeslider',

// class names

containerClassName: 'rangeslider-container',
bgClassName: 'rangeslider-bg',
rangePlotClassName: 'rangeslider-rangeplot',

maskMinClassName: 'rangeslider-mask-min',
maskMaxClassName: 'rangeslider-mask-max',
slideBoxClassName: 'rangeslider-slidebox',

grabberMinClassName: 'rangeslider-grabber-min',
grabAreaMinClassName: 'rangeslider-grabarea-min',
handleMinClassName: 'rangeslider-handle-min',

grabberMaxClassName: 'rangeslider-grabber-max',
grabAreaMaxClassName: 'rangeslider-grabarea-max',
handleMaxClassName: 'rangeslider-handle-max',

// style constants

maskColor: 'rgba(0,0,0,0.4)',

slideBoxFill: 'transparent',
slideBoxCursor: 'ew-resize',

grabAreaFill: 'transparent',
grabAreaCursor: 'col-resize',
grabAreaWidth: 10,
grabAreaMinOffset: -6,
grabAreaMaxOffset: -2,

handleWidth: 2,
handleRadius: 1,
handleFill: '#fff',
handleStroke: '#666',
};
287 changes: 0 additions & 287 deletions src/components/rangeslider/create_slider.js

This file was deleted.

13 changes: 10 additions & 3 deletions src/components/rangeslider/defaults.js
Original file line number Diff line number Diff line change
@@ -15,15 +15,19 @@ var attributes = require('./attributes');
module.exports = function handleDefaults(layoutIn, layoutOut, axName, counterAxes) {
if(!layoutIn[axName].rangeslider) return;

var containerIn = Lib.isPlainObject(layoutIn[axName].rangeslider) ?
layoutIn[axName].rangeslider : {},
// not super proud of this (maybe store _ in axis object instead
if(!Lib.isPlainObject(layoutIn[axName].rangeslider)) {
layoutIn[axName].rangeslider = {};
}

var containerIn = layoutIn[axName].rangeslider,
containerOut = layoutOut[axName].rangeslider = {};

function coerce(attr, dflt) {
return Lib.coerce(containerIn, containerOut, attributes, attr, dflt);
}

coerce('bgcolor');
coerce('bgcolor', layoutOut.plot_bgcolor);
coerce('bordercolor');
coerce('borderwidth');
coerce('thickness');
@@ -48,4 +52,7 @@ module.exports = function handleDefaults(layoutIn, layoutOut, axName, counterAxe
layoutOut[ax] = opposing;
});
}

// to map back range slider (auto) range
containerOut._input = containerIn;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to delete containerIn._input before this to avoid a loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what kind of loop are you referring to here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

containerOut._input = { 
  /* the containerIn */, 
  _input: { 
    /* the previous containerIn */, 
    _input: { 
      /* the previous conta...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_input is always linked to the layout as passed to Plotly.plot(gd, data, layout) - which doesn't know anything about containerOut.

};
Loading