-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Apply and ensure stroke event only to activate editable shapes #4810
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
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1089,7 +1089,7 @@ describe('Activate and edit editable shapes', function() { | |||||
afterEach(destroyGraphDiv); | ||||||
|
||||||
['mouse'].forEach(function(device) { | ||||||
it('@flaky reactangle using' + device, function(done) { | ||||||
it('@flaky reactangle using ' + device, function(done) { | ||||||
var i = 0; // shape index | ||||||
|
||||||
Plotly.newPlot(gd, { | ||||||
|
@@ -1224,7 +1224,7 @@ describe('Activate and edit editable shapes', function() { | |||||
.then(done); | ||||||
}); | ||||||
|
||||||
it('@flaky circle using' + device, function(done) { | ||||||
it('@flaky circle using ' + device, function(done) { | ||||||
var i = 1; // shape index | ||||||
|
||||||
Plotly.newPlot(gd, { | ||||||
|
@@ -1281,7 +1281,7 @@ describe('Activate and edit editable shapes', function() { | |||||
.then(done); | ||||||
}); | ||||||
|
||||||
it('@flaky closed-path using' + device, function(done) { | ||||||
it('@flaky closed-path using ' + device, function(done) { | ||||||
var i = 2; // shape index | ||||||
|
||||||
Plotly.newPlot(gd, { | ||||||
|
@@ -1326,7 +1326,7 @@ describe('Activate and edit editable shapes', function() { | |||||
.then(done); | ||||||
}); | ||||||
|
||||||
it('@flaky bezier curves using' + device, function(done) { | ||||||
it('@flaky bezier curves using ' + device, function(done) { | ||||||
var i = 5; // shape index | ||||||
|
||||||
Plotly.newPlot(gd, { | ||||||
|
@@ -1371,7 +1371,7 @@ describe('Activate and edit editable shapes', function() { | |||||
.then(done); | ||||||
}); | ||||||
|
||||||
it('@flaky multi-cell path using' + device, function(done) { | ||||||
it('@flaky multi-cell path using ' + device, function(done) { | ||||||
var i = 6; // shape index | ||||||
|
||||||
Plotly.newPlot(gd, { | ||||||
|
@@ -1426,3 +1426,123 @@ describe('Activate and edit editable shapes', function() { | |||||
}); | ||||||
}); | ||||||
}); | ||||||
|
||||||
|
||||||
describe('Activate and edit editable shapes', function() { | ||||||
var gd; | ||||||
|
||||||
beforeEach(function() { | ||||||
gd = createGraphDiv(); | ||||||
}); | ||||||
|
||||||
afterEach(destroyGraphDiv); | ||||||
|
||||||
it('should not set pointer-events for non-editable shapes i.e. to allow pan/zoom/hover work inside shapes', function(done) { | ||||||
Plotly.newPlot(gd, { | ||||||
data: [{ | ||||||
mode: 'markers', | ||||||
x: [1, 3, 3], | ||||||
y: [2, 1, 3] | ||||||
}], | ||||||
layout: { | ||||||
shapes: [ | ||||||
{ | ||||||
x0: 1.5, | ||||||
x1: 2.5, | ||||||
y0: 1.5, | ||||||
y1: 2.5, | ||||||
fillcolor: 'blue' | ||||||
} | ||||||
] | ||||||
} | ||||||
}) | ||||||
|
||||||
.then(function() { | ||||||
var el = Plotly.d3.selectAll('.shapelayer path')[0][0]; | ||||||
var pointerEvents = el.style['pointer-events']; | ||||||
expect(pointerEvents).not.toBe('all'); | ||||||
expect(pointerEvents).not.toBe('stroke'); | ||||||
expect(pointerEvents).toBe(''); | ||||||
}) | ||||||
|
||||||
.catch(failTest) | ||||||
.then(done); | ||||||
}); | ||||||
|
||||||
it('should provide invisible border & set pointer-events to "stroke" for editable shapes i.e. to allow shape activation', function(done) { | ||||||
Plotly.newPlot(gd, { | ||||||
data: [{ | ||||||
mode: 'markers', | ||||||
x: [1, 3, 3], | ||||||
y: [2, 1, 3] | ||||||
}], | ||||||
layout: { | ||||||
shapes: [ | ||||||
{ | ||||||
editable: true, | ||||||
x0: 1.5, | ||||||
x1: 2.5, | ||||||
y0: 1.5, | ||||||
y1: 2.5, | ||||||
fillcolor: 'blue', | ||||||
line: { | ||||||
width: 0, | ||||||
dash: 'dash', | ||||||
color: 'black' | ||||||
} | ||||||
} | ||||||
] | ||||||
} | ||||||
}) | ||||||
|
||||||
.then(function() { | ||||||
var el = Plotly.d3.selectAll('.shapelayer path')[0][0]; | ||||||
expect(el.style['pointer-events']).toBe('stroke'); | ||||||
expect(el.style.stroke).toBe('rgb(0, 0, 0)'); // no color | ||||||
expect(el.style['stroke-opacity']).toBe('0'); // invisible | ||||||
expect(el.style['stroke-width']).toBe('5px'); // some pixels to activate shape | ||||||
}) | ||||||
|
||||||
.catch(failTest) | ||||||
.then(done); | ||||||
}); | ||||||
|
||||||
it('should not provide invisible border & set pointer-events to "stroke" for shapes made editable via config', function(done) { | ||||||
Plotly.newPlot(gd, { | ||||||
data: [{ | ||||||
mode: 'markers', | ||||||
x: [1, 3, 3], | ||||||
y: [2, 1, 3] | ||||||
}], | ||||||
layout: { | ||||||
shapes: [ | ||||||
{ | ||||||
x0: 1.5, | ||||||
x1: 2.5, | ||||||
y0: 1.5, | ||||||
y1: 2.5, | ||||||
fillcolor: 'blue', | ||||||
line: { | ||||||
width: 0, | ||||||
dash: 'dash', | ||||||
color: 'black' | ||||||
} | ||||||
} | ||||||
] | ||||||
}, onfig: { | ||||||
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.
Suggested change
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. typo of the week |
||||||
editable: true | ||||||
} | ||||||
}) | ||||||
|
||||||
.then(function() { | ||||||
var el = Plotly.d3.selectAll('.shapelayer path')[0][0]; | ||||||
expect(el.style['pointer-events']).toBe(''); | ||||||
expect(el.style.stroke).toBe('rgb(0, 0, 0)'); // no color | ||||||
expect(el.style['stroke-opacity']).toBe('0'); // invisible | ||||||
expect(el.style['stroke-width']).toBe('0px'); // no extra pixels | ||||||
}) | ||||||
|
||||||
.catch(failTest) | ||||||
.then(done); | ||||||
}); | ||||||
}); |
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.
As long as this is scoped to
options.editable === true
, can't we still allow clicking on the fill when it's mostly opaque?>0.5
seems a fine cutoff to me. I feel like that's the behavior people will expect - most importantly when there's no stroke but even when there is as long as there's a strong fill.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.
Revised in 078c007.