-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Scattergl lasso #1657
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
Scattergl lasso #1657
Changes from 61 commits
8fe669b
c1a4c0c
08f0738
97b827e
3d0b325
e7e4843
6c29193
6d4f9a5
cf73fbe
d3427c0
190d3c7
9921fb9
4bff013
ab07db3
1a3ce6d
eb4654d
920127d
fb84a06
82c71eb
7085146
6de41e6
86d7d65
d21176b
8a1c8b8
82610d1
74028eb
e1da55b
4c0d822
5d35300
7a952b1
b3bc7cb
c293529
4e6bff1
5d07d99
6fb7c57
3cb6ab1
b0f0ed3
a74b301
73ab98d
8b8d2e3
1451802
de115d3
3a30ae1
1c61a47
9f57eff
c60fb1d
3921fdd
07b4c7c
6ac722d
2ceede1
33dda89
baabafe
0b7a924
d76d64d
58b3654
bbda3e7
6bfbd83
6c08dc3
1e4e25d
b92059a
d4aad3f
c7b551c
27811d6
ab30f93
debdd46
9d5d411
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 |
---|---|---|
|
@@ -12,23 +12,18 @@ | |
var Scene2D = require('./scene2d'); | ||
var Plots = require('../plots'); | ||
var xmlnsNamespaces = require('../../constants/xmlns_namespaces'); | ||
|
||
var constants = require('../cartesian/constants'); | ||
var Cartesian = require('../cartesian'); | ||
|
||
exports.name = 'gl2d'; | ||
|
||
exports.attr = ['xaxis', 'yaxis']; | ||
|
||
exports.idRoot = ['x', 'y']; | ||
|
||
exports.idRegex = { | ||
x: /^x([2-9]|[1-9][0-9]+)?$/, | ||
y: /^y([2-9]|[1-9][0-9]+)?$/ | ||
}; | ||
exports.idRegex = constants.idRegex; | ||
|
||
exports.attrRegex = { | ||
x: /^xaxis([2-9]|[1-9][0-9]+)?$/, | ||
y: /^yaxis([2-9]|[1-9][0-9]+)?$/ | ||
}; | ||
exports.attrRegex = constants.attrRegex; | ||
|
||
exports.attributes = require('../cartesian/attributes'); | ||
|
||
|
@@ -82,6 +77,15 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) | |
delete oldFullLayout._plots[id]; | ||
} | ||
} | ||
|
||
// since we use cartesian interactions, do cartesian clean | ||
Cartesian.clean.apply(this, arguments); | ||
}; | ||
|
||
exports.drawFramework = function(gd) { | ||
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. Nice. We probably don't all of this or at least we should be able to reuse the exports.drawFramework = Cartesian.drawFramework; 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. Done. Gotta take a second look on optimization. |
||
if(!gd._context.staticPlot) { | ||
Cartesian.drawFramework(gd); | ||
} | ||
}; | ||
|
||
exports.toSVG = function(gd) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ var now = require('right-now'); | |
var createView = require('3d-view'); | ||
var mouseChange = require('mouse-change'); | ||
var mouseWheel = require('mouse-wheel'); | ||
var mouseOffset = require('mouse-event-offset'); | ||
|
||
function createCamera(element, options) { | ||
element = element || document.body; | ||
|
@@ -179,8 +180,24 @@ function createCamera(element, options) { | |
return false; | ||
}); | ||
|
||
var lastX = 0, lastY = 0; | ||
mouseChange(element, function(buttons, x, y, mods) { | ||
var lastX = 0, lastY = 0, lastMods = {shift: false, control: false, alt: false, meta: false}; | ||
mouseChange(element, handleInteraction); | ||
|
||
// enable simple touch interactions | ||
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. Amazing 🎉 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. That is unmerged #1507 here |
||
element.addEventListener('touchstart', function(ev) { | ||
var xy = mouseOffset(ev.changedTouches[0], element); | ||
handleInteraction(0, xy[0], xy[1], lastMods); | ||
handleInteraction(1, xy[0], xy[1], lastMods); | ||
}); | ||
element.addEventListener('touchmove', function(ev) { | ||
var xy = mouseOffset(ev.changedTouches[0], element); | ||
handleInteraction(1, xy[0], xy[1], lastMods); | ||
}); | ||
element.addEventListener('touchend', function() { | ||
handleInteraction(0, lastX, lastY, lastMods); | ||
}); | ||
|
||
function handleInteraction(buttons, x, y, mods) { | ||
var keyBindingMode = camera.keyBindingMode; | ||
|
||
if(keyBindingMode === false) return; | ||
|
@@ -225,9 +242,10 @@ function createCamera(element, options) { | |
|
||
lastX = x; | ||
lastY = y; | ||
lastMods = mods; | ||
|
||
return true; | ||
}); | ||
} | ||
|
||
mouseWheel(element, function(dx, dy) { | ||
if(camera.keyBindingMode === false) return; | ||
|
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.
This is an interesting patch. I wonder if this might be fixing an undiscovered bugs(s).
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.
That is taken from https://github.com/dfcreative/plotly.js/blob/6de41e6d555d038299aa0aef7e075804f011db49/src/plots/cartesian/axes.js#L1657, just optimized it a drop