function computeDelta(visual) {
// Compute the distance from the right/bottom edge of the visual
// viewport to the same edge of the layout viewport and add the desired
// offset to that.
// We can ignore scrollbar width here since the scrollbar is layouted at
// the right/bottom edge of this content, not of this window in the case
// of containerful scrolling.
return visual - (visual / RESOLUTION) + OFFSET_CSS_PX;
}
async function test() {
const cases = [
{
x: 0,
y: 0,
dx: (width) => -computeDelta(width),
dy: () => 0,
expected: {
x: [OFFSET_CSS_PX, "x-offset was adjusted"],
y: [0, "y-offset was not affected"],
},
},
{
x: OFFSET_CSS_PX,
y: 0,
dx: () => 0,
dy: (height) => -computeDelta(height),
expected: {
x: [OFFSET_CSS_PX, "x-offset was not affected"],
y: [OFFSET_CSS_PX, "y-offset was adjusted"],
},
},
];
for (let c of cases) {
await promiseNativeTouchDrag(window,
c.x,
c.y,
c.dx(document.documentElement.clientWidth),
c.dy(document.documentElement.clientHeight));
await promiseApzFlushedRepaints();
is(window.scrollX, c.expected.x[0], c.expected.x[1]);
is(window.scrollY, c.expected.y[0], c.expected.y[1]);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.