-
-
Notifications
You must be signed in to change notification settings - Fork 19
Bugfix: Prevent mobile yank back #741
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 all commits
Commits
Show all changes
2 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| import { expect } from 'chai'; | ||
| import * as Blockly from 'blockly'; | ||
| import { installWorkspaceJumpDebug } from '../main/blocklyinit.js'; | ||
| import { defineControlBlocks } from '../blocks/control.js'; | ||
|
|
||
| export function runBlocklyInitTests(_flock) { | ||
| describe('main/blocklyinit @blocklyinit', function () { | ||
| let workspace; | ||
| let container; | ||
|
|
||
| before(function () { | ||
| defineControlBlocks(); | ||
| }); | ||
|
|
||
| beforeEach(function () { | ||
| container = document.createElement('div'); | ||
| container.style.width = '300px'; | ||
| container.style.height = '200px'; | ||
| document.body.appendChild(container); | ||
| workspace = Blockly.inject(container, { | ||
| move: { scrollbars: { horizontal: true, vertical: true }, drag: true, wheel: true }, | ||
| }); | ||
|
|
||
| // scroll() clamps to the content bounding box (see blockly_compressed.js): | ||
| // a single block barely bigger than the viewport gives zero scroll slack, | ||
| // so the box has to be much larger than the viewport in both dimensions to | ||
| // leave real scroll range for the assertions below. | ||
| const near = workspace.newBlock('wait'); | ||
| near.initSvg(); | ||
| near.render(); | ||
|
|
||
| const far = workspace.newBlock('wait'); | ||
| far.initSvg(); | ||
| far.render(); | ||
| far.moveBy(3000, 3000); | ||
|
|
||
| installWorkspaceJumpDebug(workspace); | ||
| }); | ||
|
|
||
| afterEach(function () { | ||
| workspace?.dispose(); | ||
| container?.remove(); | ||
| }); | ||
|
|
||
| describe('focus-scroll jump suppression', function () { | ||
| // Named to match the stack-trace check in installWorkspaceJumpDebug, which | ||
| // only reacts to Blockly's own focus-follow path (scrollBoundsIntoView / | ||
| // onNodeFocus), mirroring the real call site in blockly_compressed.js. | ||
| function scrollBoundsIntoView(x, y) { | ||
| workspace.scroll(x, y); | ||
| } | ||
|
|
||
| it('suppresses a large horizontal jump but keeps the accompanying vertical scroll after a direct canvas tap', function () { | ||
| workspace | ||
| .getParentSvg() | ||
| .dispatchEvent(new PointerEvent('pointerdown', { bubbles: true })); | ||
|
|
||
| const beforeX = workspace.scrollX; | ||
| const beforeY = workspace.scrollY; | ||
| scrollBoundsIntoView(beforeX - 400, beforeY - 50); | ||
|
|
||
| expect(workspace.scrollX).to.equal(beforeX); | ||
| expect(workspace.scrollY).to.equal(beforeY - 50); | ||
| }); | ||
|
|
||
| it('applies both axes normally when there was no recent canvas tap', function () { | ||
| const beforeX = workspace.scrollX; | ||
| const beforeY = workspace.scrollY; | ||
| scrollBoundsIntoView(beforeX - 400, beforeY - 50); | ||
|
|
||
| expect(workspace.scrollX).to.equal(beforeX - 400); | ||
| expect(workspace.scrollY).to.equal(beforeY - 50); | ||
| }); | ||
|
|
||
| it('applies both axes normally for a non-focus-driven scroll even after a canvas tap', function () { | ||
| workspace | ||
| .getParentSvg() | ||
| .dispatchEvent(new PointerEvent('pointerdown', { bubbles: true })); | ||
|
|
||
| const beforeX = workspace.scrollX; | ||
| const beforeY = workspace.scrollY; | ||
| workspace.scroll(beforeX - 400, beforeY - 50); | ||
|
|
||
| expect(workspace.scrollX).to.equal(beforeX - 400); | ||
| expect(workspace.scrollY).to.equal(beforeY - 50); | ||
| }); | ||
| }); | ||
| }); | ||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.