mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 22:48:11 +00:00
LibWeb: Add basic support for requestAnimationFrame()
We now support rAF, driven by GUI::DisplayLink callbacks. It's a bit strange how we keep registering new callbacks over and over. That's something we can definitely optimize. This allows you to update animations/whatever without doing it more often than the browser can display.
This commit is contained in:
parent
424a3f5ac3
commit
39045bfde8
5 changed files with 56 additions and 2 deletions
24
Base/home/anon/www/raf.html
Normal file
24
Base/home/anon/www/raf.html
Normal file
|
@ -0,0 +1,24 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head><title>rAF test</title></head>
|
||||
<body>
|
||||
<canvas id=c width=300 height=300></canvas>
|
||||
<script>
|
||||
c = document.getElementById('c');
|
||||
x = c.getContext("2d");
|
||||
x.fillStyle = 'black';
|
||||
x.fillRect(0, 0, c.width, c.height);
|
||||
function raf() {
|
||||
x.fillStyle = 'red';
|
||||
x.fillRect(
|
||||
Math.random() * c.width,
|
||||
Math.random() * c.height,
|
||||
Math.random() * 10,
|
||||
Math.random() * 10
|
||||
);
|
||||
requestAnimationFrame(raf);
|
||||
}
|
||||
requestAnimationFrame(raf);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -24,6 +24,7 @@ h1 {
|
|||
<p>Some small test pages:</p>
|
||||
<ul>
|
||||
<li><a href="demo.html">fun demo</a></li>
|
||||
<li><a href="raf.html">requestAnimationFrame test</a></li>
|
||||
<li><a href="canvas.html">canvas 2D test</a></li>
|
||||
<li><a href="events.html">simple DOM events test</a></li>
|
||||
<li><a href="dom.html">simple DOM JS test</a></li>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue