forked from plotly/plotly.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Pass MouseEvent to the user #9
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
Open
n-riesco
wants to merge
27
commits into
master
Choose a base branch
from
wip-20170314-events
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 17 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
580d5fe
events: plotly_click, plotly_hover, plotly_unhover
n-riesco fe4239b
events: update tests
n-riesco 7a90972
events: test modified clicks
n-riesco aea866e
events: do not use `new MouseEvent(evt)`
n-riesco e809b23
events: try-catch `new MouseEvent(type, evt)`
n-riesco 2e6fb16
test: update helper function click
n-riesco 550a257
events: test plotly_click in a pie plot
n-riesco d7e56cf
events: fix plotly_click in pie plots
n-riesco 40dc522
events: test plotly_hover in pie plots
n-riesco 85f72ff
events: add event to plotly_hover
n-riesco 5f5bb9e
events: test plotly_unhover in pie plots
n-riesco 8d5697b
events: add event to plotly_unhover
n-riesco 9cf50c2
events: test plotly events in ternary plots
n-riesco 27eb8c3
events: fix plotly events in geo plots
n-riesco 3584bba
events: test plotly events in geo plots
n-riesco 60ee153
events: fix plotly events in mapbox plots
n-riesco dcdda6f
events: test plotly events in mapbox plots
n-riesco 194243d
events: define variable hasUserCalledHover
n-riesco 20ff1a0
events: do not hard-code HOVERMINTIME
n-riesco 3c41961
events: move geo tests to get_test.js
n-riesco 00baba0
event: fix regression in pie interactions
n-riesco 5cdf009
events: move pie tests to hover_pie_test.js
n-riesco 76e382e
events: move ternary tests to ternary_test.js
n-riesco f679bbf
pie: test issue #902
n-riesco 91cc175
pie: emit `plotly_hover` even if hoverinfo is none
n-riesco 499c393
pie: test issue #1456
n-riesco 9e10119
pie: Fix undefined trace in 'plotly_click'
n-riesco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,8 +166,8 @@ proto.createMap = function(calcData, fullLayout, resolve, reject) { | |
Fx.hover(gd, evt, self.id); | ||
}); | ||
|
||
map.on('click', function() { | ||
Fx.click(gd, { target: true }); | ||
map.on('click', function(evt) { | ||
Fx.click(gd, evt.originalEvent); | ||
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. Very nice here. Thanks! |
||
}); | ||
|
||
function unhover() { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
var mouseEvent = require('./mouse_event'); | ||
|
||
module.exports = function click(x, y) { | ||
mouseEvent('mousemove', x, y); | ||
mouseEvent('mousedown', x, y); | ||
mouseEvent('mouseup', x, y); | ||
module.exports = function click(x, y, opts) { | ||
mouseEvent('mousemove', x, y, opts); | ||
mouseEvent('mousedown', x, y, opts); | ||
mouseEvent('mouseup', x, y, opts); | ||
mouseEvent('click', x, y, opts); | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,18 @@ module.exports = function(type, x, y, opts) { | |
if(opts && opts.buttons) { | ||
fullOpts.buttons = opts.buttons; | ||
} | ||
if(opts && opts.altKey) { | ||
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. Thanks! |
||
fullOpts.altKey = opts.altKey; | ||
} | ||
if(opts && opts.ctrlKey) { | ||
fullOpts.ctrlKey = opts.ctrlKey; | ||
} | ||
if(opts && opts.metaKey) { | ||
fullOpts.metaKey = opts.metaKey; | ||
} | ||
if(opts && opts.shiftKey) { | ||
fullOpts.shiftKey = opts.shiftKey; | ||
} | ||
|
||
var el = (opts && opts.element) || document.elementFromPoint(x, y), | ||
ev; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Great. This will work for all subplots that call
Fx.hover
if I remember correctly that means: cartesian, ternary, geo and mapbox subplots. @n-riesco would you mind double checking?Now, at the very least, we should make sure
event
is passed in pie chart hover data. Pie hover is a little different but shouldn't make it too hard to implement.This leaves our gl2d, gl3d and
parcoords
(and polar but who cares about polar?). I'll be ok leaving them out of the first iteration. We should instead spent some time down the road merging their hover logic withFx.hover
.Uh oh!
There was an error while loading. Please reload this page.
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.
@etpinard It doesn't work for pie, ternary, geo or mapbox, because when they call to
Fx.click(gd, evt)
they make up anevt
.I reckon that to make it work for all these types of subplots, first I need to locate where they call
Fx.click
,Fx.hover
andFx.unhover
and then see if it's possible to send the original event.For example, here: why do we need to set the event to
{target: true}
? Is is OK if we just doFx.click(gd, d3.event);
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 sounds ok to me, yes.