[go: nahoru, domu]

blob: 26e19f3fc6344186e7ddfca52ce3bd4f27c9c5a5 [file] [log] [blame]
<!DOCTYPE html>
<style>
#box {
width: 100px;
height: 100px;
background-color: #00ff00;
/*
* Force compositing.
* TODO(majidvp): Should not be needed when http://crbug.com/776533 is fixed.
*/
will-change: transform;
}
#covered {
width: 100px;
height: 100px;
background-color: #ff8080;
}
#scroller {
overflow: auto;
height: 100px;
width: 100px;
/*
* Force compositing.
* TODO(crbug.com/776533): Shouldn't be needed - we should fallback to main if scroller isn't composited.
*/
will-change: transform;
}
#contents {
height: 1000px;
width: 100%;
}
</style>
<div id="box"></div>
<div id="covered"></div>
<div id="scroller">
<div id="contents"></div>
</div>
<script id="visual_update" type="text/worklet">
registerAnimator("test_animator", class {
animate(currentTime, effect) {
effect.localTime = currentTime;
}
});
</script>
<script src="resources/animation-worklet-tests.js"></script>
<script>
if (window.testRunner) {
testRunner.waitUntilDone();
}
runInAnimationWorklet(
document.getElementById('visual_update').textContent
).then(()=>{
const box = document.getElementById('box');
const effect = new KeyframeEffect(box,
[
{ transform: 'translateY(0)', opacity: 1},
{ transform: 'translateY(200px)', opacity: 0}
], {
duration: 1000,
}
);
const scroller = document.getElementById('scroller');
const timeline = new ScrollTimeline({ scrollSource: scroller, timeRange: 1000, orientation: 'block' });
const animation = new WorkletAnimation('test_animator', [effect], timeline, {});
animation.play();
// Move the scroller to the halfway point.
const maxScroll = scroller.scrollHeight - scroller.clientHeight;
scroller.scrollTop = 0.5 * maxScroll;
if (window.testRunner) {
waitTwoAnimationFrames(_ => {
testRunner.notifyDone();
});
}
});
</script>