-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
161 additions
and
4 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { test, expect } from "@playwright/test"; | ||
import { | ||
storyUrl, | ||
scrollableSelector, | ||
getLastItem, | ||
scrollWithTouch, | ||
getScrollTop, | ||
} from "./utils"; | ||
|
||
test.describe("check if scroll jump compensation in iOS WebKit works", () => { | ||
test("reverse scroll", async ({ page }) => { | ||
await page.goto(storyUrl("basics-vlist--reverse")); | ||
|
||
const component = await page.waitForSelector(scrollableSelector); | ||
await component.waitForElementState("stable"); | ||
|
||
// check if last is displayed | ||
const last = await getLastItem(component); | ||
await expect(last.text).toEqual("999"); | ||
await expect(last.bottom).toBeLessThanOrEqual(1); // FIXME: may not be 0 in Safari | ||
|
||
await component.tap(); | ||
|
||
const [w, h] = await page.evaluate(() => [ | ||
window.outerWidth, | ||
window.outerHeight, | ||
]); | ||
const centerX = w / 2; | ||
const centerY = h / 2; | ||
|
||
let top: number = await getScrollTop(component); | ||
for (let i = 0; i < 10; i++) { | ||
await scrollWithTouch(component, { | ||
fromX: centerX, | ||
fromY: centerY - h / 8, | ||
toX: centerX, | ||
toY: centerY + h / 8, | ||
}); | ||
|
||
// wait flush | ||
const [nextTopBeforeFlush /* nextLastItemBeforeFlush */] = | ||
await Promise.all([ | ||
getScrollTop(component), | ||
// getLastItem(component), | ||
]); | ||
await page.waitForTimeout(300); | ||
const [nextTop /* nextLastItem */] = await Promise.all([ | ||
getScrollTop(component), | ||
// getLastItem(component), | ||
]); | ||
|
||
expect(nextTop).toBeLessThan(top); | ||
expect(nextTop).not.toBe(nextTopBeforeFlush); | ||
// expect(nextLastItem).toEqual(nextLastItemBeforeFlush); | ||
|
||
top = nextTop; | ||
} | ||
}); | ||
|
||
// TODO momentum scroll | ||
|
||
// TODO shift/unshift | ||
|
||
// TODO display none | ||
}); |
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