-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Legend scroll fix #2426
Merged
Merged
Legend scroll fix #2426
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f75f5ba
fix #2387 - prevent legend scrolling from scrollBox drag or right click
alexcjohnson ec42784
grab the legend scrollbar at the cursor, not at its middle
alexcjohnson 246b77f
make legend scrollbar scale to the visible fraction
alexcjohnson 569b378
fix #808 - update scrollBar when changing other legend attributes
alexcjohnson 5660bf5
:hocho: `call` when not in a chain
alexcjohnson f2d8cfd
turn `scrollBoxY` into a positive number
alexcjohnson 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 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 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 |
---|---|---|
|
@@ -99,15 +99,15 @@ describe('The legend', function() { | |
2 * constants.scrollBarMargin; | ||
var initialDataScroll = getScroll(gd); | ||
var wheelDeltaY = 100; | ||
var finalDataScroll = Lib.constrain(initialDataScroll - | ||
var finalDataScroll = Lib.constrain(initialDataScroll + | ||
wheelDeltaY / scrollBarYMax * scrollBoxYMax, | ||
-scrollBoxYMax, 0); | ||
0, scrollBoxYMax); | ||
|
||
legend.dispatchEvent(scrollTo(wheelDeltaY)); | ||
|
||
expect(getScroll(gd)).toBe(finalDataScroll); | ||
expect(scrollBox.getAttribute('transform')).toBe( | ||
'translate(0, ' + finalDataScroll + ')'); | ||
'translate(0, ' + -finalDataScroll + ')'); | ||
}); | ||
|
||
function dragScroll(element, rightClick) { | ||
|
@@ -120,9 +120,9 @@ describe('The legend', function() { | |
2 * constants.scrollBarMargin; | ||
var initialDataScroll = getScroll(gd); | ||
var dy = 50; | ||
var finalDataScroll = Lib.constrain(initialDataScroll - | ||
var finalDataScroll = Lib.constrain(initialDataScroll + | ||
dy / scrollBarYMax * scrollBoxYMax, | ||
-scrollBoxYMax, 0); | ||
0, scrollBoxYMax); | ||
|
||
var y0 = scrollBarBB.top + scrollBarBB.height / 5; | ||
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. notice that I moved the drag point away from the center of the |
||
var y1 = y0 + dy; | ||
|
@@ -152,7 +152,7 @@ describe('The legend', function() { | |
var dataScroll = getScroll(gd); | ||
expect(dataScroll).toBeCloseTo(finalDataScroll, 3); | ||
expect(scrollBox.getAttribute('transform')).toBe( | ||
'translate(0, ' + dataScroll + ')'); | ||
'translate(0, ' + -dataScroll + ')'); | ||
}); | ||
|
||
it('should not scroll on dragging the scrollbox', function() { | ||
|
@@ -162,7 +162,7 @@ describe('The legend', function() { | |
var dataScroll = getScroll(gd); | ||
expect(dataScroll).not.toBeCloseTo(finalDataScroll, 3); | ||
expect(scrollBox.getAttribute('transform')).toBe( | ||
'translate(0, ' + dataScroll + ')'); | ||
'translate(0, ' + -dataScroll + ')'); | ||
}); | ||
|
||
it('should not scroll on dragging the scrollbar with a right click', function() { | ||
|
@@ -172,7 +172,7 @@ describe('The legend', function() { | |
var dataScroll = getScroll(gd); | ||
expect(dataScroll).not.toBeCloseTo(finalDataScroll, 3); | ||
expect(scrollBox.getAttribute('transform')).toBe( | ||
'translate(0, ' + dataScroll + ')'); | ||
'translate(0, ' + -dataScroll + ')'); | ||
}); | ||
|
||
it('removes scroll bar and handlers when switching to horizontal', function(done) { | ||
|
@@ -214,15 +214,15 @@ describe('The legend', function() { | |
expect(scrollBarHeight1).toBeGreaterThan(scrollBarHeight); | ||
|
||
// we haven't quite removed the scrollbar, but we should have clipped the scroll value | ||
return Plotly.deleteTraces(gd, [0, 1, 2, 3, 4, 5, 6, 7]); | ||
return Plotly.deleteTraces(gd, [0, 1, 2, 3, 4, 5, 6]); | ||
}) | ||
.then(function() { | ||
expect(getScroll(gd)).toBeGreaterThan(dataScroll + 1); | ||
expect(getScroll(gd)).toBeLessThan(dataScroll - 1); | ||
var scrollBarHeight2 = getScrollBar().getBoundingClientRect().height; | ||
expect(scrollBarHeight2).toBeGreaterThan(scrollBarHeight1); | ||
|
||
// now no more scrollBar | ||
return Plotly.deleteTraces(gd, [0, 1]); | ||
return Plotly.deleteTraces(gd, [0, 1, 2]); | ||
}) | ||
.then(function() { | ||
expect(hasScrollBar()).toBe(false); | ||
|
@@ -251,7 +251,7 @@ describe('The legend', function() { | |
expect(+toggle.parentNode.style.opacity).toBeLessThan(1); | ||
expect(getScroll(gd)).toBe(dataScroll); | ||
expect(scrollBox.getAttribute('transform')).toBe( | ||
'translate(0, ' + dataScroll + ')'); | ||
'translate(0, ' + -dataScroll + ')'); | ||
done(); | ||
}, DBLCLICKDELAY * 2); | ||
}); | ||
|
@@ -289,7 +289,7 @@ describe('The legend', function() { | |
expect(+toggle.parentNode.style.opacity).toBeLessThan(1); | ||
expect(getScroll(gd)).toBe(dataScroll); | ||
expect(scrollBox.getAttribute('transform')).toBe( | ||
'translate(0, ' + dataScroll + ')'); | ||
'translate(0, ' + -dataScroll + ')'); | ||
expect(scrollBar.getAttribute('width')).toBeGreaterThan(0); | ||
expect(scrollBar.getAttribute('height')).toBeGreaterThan(0); | ||
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.
Thank you!