Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Side by Side Diff: third_party/WebKit/ManualTests/compositor-worker/scroll-animation.js

Issue 1547893003: WIP - compositor worker mega patch. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 (function(scope) {
2 "use strict";
3
4 scope.isMain = function() {
5 return scope.window;
6 };
7
8 scope.tick = function(timestamp) {
9 var newOffset = (Math.sin(timestamp ) + 1) * 500;
10 scroller.scrollTop = newOffset;
11 scope.requestAnimationFrame(tick);
12 };
13
14 scope.initWorker = function() {
15 console.log("init worker");
16 self.onmessage = function(e) {
17 console.log("onmessage");
18 scope.scroller = e.data[0];
19 scope.requestAnimationFrame(tick);
20 };
21 };
22
23 scope.initMain = function() {
24 console.log("init main");
25
26 scope.worker = new CompositorWorker("scroll-animation.js");
27 var scrollElement = document.getElementById("scroller");
28 scope.scroller = new CompositorProxy(scrollElement, ['scrollTop']);
29 scrollElement.addEventListener("scroll", function(e) {
30 this.style.top = (910 - e.target.scrollTop) + "px";
31 var start = new Date();
32 while (true) {
33 var now = new Date();
34 if (now.getTime() - start.getTime() > 200)
35 break;
36 }
37 }.bind(document.getElementById("thingy")));
38 worker.postMessage([scroller]);
39 };
40
41 if (isMain())
42 initMain();
43 else
44 initWorker();
45 })(self);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698