Skip to content

Commit

Permalink
MINSELECT bigger than MINDRAG
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcjohnson committed Jan 6, 2016
1 parent 342f991 commit b5c090f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
3 changes: 3 additions & 0 deletions src/plots/cartesian/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ module.exports = {
// pixels to move mouse before you stop clamping to starting point
MINDRAG: 8,

// smallest dimension allowed for a select box
MINSELECT: 12,

// smallest dimension allowed for a zoombox
MINZOOM: 20,

Expand Down
22 changes: 11 additions & 11 deletions src/plots/cartesian/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var constants = require('./constants');

var filteredPolygon = polygon.filter;
var polygonTester = polygon.tester;
var MINDRAG = constants.MINDRAG;
var MINSELECT = constants.MINSELECT;

function getAxId(ax) { return ax._id; }

Expand Down Expand Up @@ -98,23 +98,23 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
dy = Math.abs(y1 - y0);

if(mode === 'select') {
if(dy < Math.min(dx * 0.6, MINDRAG)) {
if(dy < Math.min(dx * 0.6, MINSELECT)) {
// horizontal motion: make a vertical box
poly = polygonTester([[x0, 0], [x0, ph], [x1, ph], [x1, 0]]);
// extras to guide users in keeping a straight selection
corners.attr('d', 'M' + poly.xmin + ',' + (y0 - MINDRAG) +
'h-4v' + (2 * MINDRAG) + 'h4Z' +
'M' + (poly.xmax - 1) + ',' + (y0 - MINDRAG) +
'h4v' + (2 * MINDRAG) + 'h-4Z');
corners.attr('d', 'M' + poly.xmin + ',' + (y0 - MINSELECT) +
'h-4v' + (2 * MINSELECT) + 'h4Z' +
'M' + (poly.xmax - 1) + ',' + (y0 - MINSELECT) +
'h4v' + (2 * MINSELECT) + 'h-4Z');

}
else if(dx < Math.min(dy * 0.6, MINDRAG)) {
else if(dx < Math.min(dy * 0.6, MINSELECT)) {
// vertical motion: make a horizontal box
poly = polygonTester([[0, y0], [0, y1], [pw, y1], [pw, y0]]);
corners.attr('d', 'M' + (x0 - MINDRAG) + ',' + poly.ymin +
'v-4h' + (2 * MINDRAG) + 'v4Z' +
'M' + (x0 - MINDRAG) + ',' + (poly.ymax - 1) +
'v4h' + (2 * MINDRAG) + 'v-4Z');
corners.attr('d', 'M' + (x0 - MINSELECT) + ',' + poly.ymin +
'v-4h' + (2 * MINSELECT) + 'v4Z' +
'M' + (x0 - MINSELECT) + ',' + (poly.ymax - 1) +
'v4h' + (2 * MINSELECT) + 'v-4Z');
}
else {
// diagonal motion
Expand Down

1 comment on commit b5c090f

@etpinard
Copy link
Contributor

Choose a reason for hiding this comment

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

Good enough for v1 !

We can revisit this later.

Please sign in to comment.