{"action":"created","comment":{"url":"https://api.github.com/repos/chenglou/react-motion/pulls/comments/34426557","id":34426557,"diff_hunk":"@@ -0,0 +1,117 @@\n+function isActiveSubscription(subscription) {\n+  return subscription.active;\n+}\n+\n+const prototype = {\n+  running: false,\n+  shouldStop: false,\n+  lastTime: 0,\n+  accumulatedTime: 0,\n+\n+  setOptions: function setOptions(options) {\n+    const animationLoop = this;\n+    const timeStep = animationLoop.timeStep = options.timeStep;\n+    animationLoop.timeScale = options.timeScale;\n+    animationLoop.maxSteps = options.maxSteps;\n+    animationLoop.getTime = options.getTime;\n+    animationLoop.ticker = options.ticker;\n+\n+    animationLoop.step = function step(subscriber) {\n+      if (subscriber.active) {\n+        subscriber.value = subscriber.step(subscriber.value, timeStep);\n+      }\n+    };\n+\n+    return animationLoop;\n+  },\n+\n+  subscribe: function subscribe(value, step, render) {\n+    const animationLoop = this;\n+    const subscriber = {\n+      value: value,\n+      step: step,\n+      render: render,\n+      active: true,\n+    };\n+\n+    animationLoop.state.push(subscriber);\n+\n+    return function unsubscribe() {\n+      subscriber.active = false;\n+    };\n+  },\n+\n+  loop: function loop() {\n+    const animationLoop = this;\n+    const currentTime = animationLoop.getTime();\n+\n+    if (animationLoop.shouldStop) {\n+      animationLoop.running = animationLoop.shouldStop = false;\n+      return;\n+    }\n+\n+    const timeStep = animationLoop.timeStep;\n+    const frameTime = currentTime - animationLoop.lastTime;\n+\n+    animationLoop.lastTime = currentTime;\n+    animationLoop.accumulatedTime += frameTime * animationLoop.timeScale;\n+\n+    if (animationLoop.accumulatedTime > timeStep * animationLoop.maxSteps) {\n+      animationLoop.accumulatedTime = 0;\n+    }\n+\n+    while (animationLoop.accumulatedTime > 0) {","path":"src/animationLoop.js","position":63,"original_position":63,"commit_id":"2877c7f91cfc50bf28e50bdf32d545ae794fe144","original_commit_id":"2877c7f91cfc50bf28e50bdf32d545ae794fe144","user":{"login":"nkbt","id":175264,"avatar_url":"https://avatars.githubusercontent.com/u/175264?v=3","gravatar_id":"","url":"https://api.github.com/users/nkbt","html_url":"https://github.com/nkbt","followers_url":"https://api.github.com/users/nkbt/followers","following_url":"https://api.github.com/users/nkbt/following{/other_user}","gists_url":"https://api.github.com/users/nkbt/gists{/gist_id}","starred_url":"https://api.github.com/users/nkbt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nkbt/subscriptions","organizations_url":"https://api.github.com/users/nkbt/orgs","repos_url":"https://api.github.com/users/nkbt/repos","events_url":"https://api.github.com/users/nkbt/events{/privacy}","received_events_url":"https://api.github.com/users/nkbt/received_events","type":"User","site_admin":false},"body":"You should be able to drop frames when needed not freeze the ui imo\n","created_at":"2015-07-12T22:39:44Z","updated_at":"2015-07-12T22:39:44Z","html_url":"https://github.com/chenglou/react-motion/pull/57#discussion_r34426557","pull_request_url":"https://api.github.com/repos/chenglou/react-motion/pulls/57","_links":{"self":{"href":"https://api.github.com/repos/chenglou/react-motion/pulls/comments/34426557"},"html":{"href":"https://github.com/chenglou/react-motion/pull/57#discussion_r34426557"},"pull_request":{"href":"https://api.github.com/repos/chenglou/react-motion/pulls/57"}}},"pull_request":{"url":"https://api.github.com/repos/chenglou/react-motion/pulls/57","id":39769352,"html_url":"https://github.com/chenglou/react-motion/pull/57","diff_url":"https://github.com/chenglou/react-motion/pull/57.diff","patch_url":"https://github.com/chenglou/react-motion/pull/57.patch","issue_url":"https://api.github.com/repos/chenglou/react-motion/issues/57","number":57,"state":"open","locked":false,"title":"(WIP) Implement a basic animation loop.","user":{"login":"iclanzan","id":1806943,"avatar_url":"https://avatars.githubusercontent.com/u/1806943?v=3","gravatar_id":"","url":"https://api.github.com/users/iclanzan","html_url":"https://github.com/iclanzan","followers_url":"https://api.github.com/users/iclanzan/followers","following_url":"https://api.github.com/users/iclanzan/following{/other_user}","gists_url":"https://api.github.com/users/iclanzan/gists{/gist_id}","starred_url":"https://api.github.com/users/iclanzan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iclanzan/subscriptions","organizations_url":"https://api.github.com/users/iclanzan/orgs","repos_url":"https://api.github.com/users/iclanzan/repos","events_url":"https://api.github.com/users/iclanzan/events{/privacy}","received_events_url":"https://api.github.com/users/iclanzan/received_events","type":"User","site_admin":false},"body":"I have adapted this from a [project](https://github.com/iclanzan/momentum) I started working on a few days ago.\r\n\r\nThe animation loop has the following features:\r\n\r\n+ Decoupled stepping from rendering so that stepping can be done using\r\na constant time step which is very important in any numerical\r\nintegration.\r\n+ API that allows passing in pure functions.\r\n+ Pauses when browser tab is not visible (more accurately when the\r\nticker is called too infrequently).\r\n+ Stops automatically when there are no more animations to run.\r\n+ Supports rendering with interpolation.\r\n\r\nI would really appreciate some feedback to make sure we take this in the right direction.","created_at":"2015-07-12T21:45:52Z","updated_at":"2015-07-12T22:39:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"95140667e44c8bf9b281ae73abd93196259dc386","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/chenglou/react-motion/pulls/57/commits","review_comments_url":"https://api.github.com/repos/chenglou/react-motion/pulls/57/comments","review_comment_url":"https://api.github.com/repos/chenglou/react-motion/pulls/comments{/number}","comments_url":"https://api.github.com/repos/chenglou/react-motion/issues/57/comments","statuses_url":"https://api.github.com/repos/chenglou/react-motion/statuses/2877c7f91cfc50bf28e50bdf32d545ae794fe144","head":{"label":"iclanzan:master","ref":"master","sha":"2877c7f91cfc50bf28e50bdf32d545ae794fe144","user":{"login":"iclanzan","id":1806943,"avatar_url":"https://avatars.githubusercontent.com/u/1806943?v=3","gravatar_id":"","url":"https://api.github.com/users/iclanzan","html_url":"https://github.com/iclanzan","followers_url":"https://api.github.com/users/iclanzan/followers","following_url":"https://api.github.com/users/iclanzan/following{/other_user}","gists_url":"https://api.github.com/users/iclanzan/gists{/gist_id}","starred_url":"https://api.github.com/users/iclanzan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iclanzan/subscriptions","organizations_url":"https://api.github.com/users/iclanzan/orgs","repos_url":"https://api.github.com/users/iclanzan/repos","events_url":"https://api.github.com/users/iclanzan/events{/privacy}","received_events_url":"https://api.github.com/users/iclanzan/received_events","type":"User","site_admin":false},"repo":{"id":38899465,"name":"react-motion","full_name":"iclanzan/react-motion","owner":{"login":"iclanzan","id":1806943,"avatar_url":"https://avatars.githubusercontent.com/u/1806943?v=3","gravatar_id":"","url":"https://api.github.com/users/iclanzan","html_url":"https://github.com/iclanzan","followers_url":"https://api.github.com/users/iclanzan/followers","following_url":"https://api.github.com/users/iclanzan/following{/other_user}","gists_url":"https://api.github.com/users/iclanzan/gists{/gist_id}","starred_url":"https://api.github.com/users/iclanzan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iclanzan/subscriptions","organizations_url":"https://api.github.com/users/iclanzan/orgs","repos_url":"https://api.github.com/users/iclanzan/repos","events_url":"https://api.github.com/users/iclanzan/events{/privacy}","received_events_url":"https://api.github.com/users/iclanzan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/iclanzan/react-motion","description":"A spring that solves your animation problems.","fork":true,"url":"https://api.github.com/repos/iclanzan/react-motion","forks_url":"https://api.github.com/repos/iclanzan/react-motion/forks","keys_url":"https://api.github.com/repos/iclanzan/react-motion/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iclanzan/react-motion/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iclanzan/react-motion/teams","hooks_url":"https://api.github.com/repos/iclanzan/react-motion/hooks","issue_events_url":"https://api.github.com/repos/iclanzan/react-motion/issues/events{/number}","events_url":"https://api.github.com/repos/iclanzan/react-motion/events","assignees_url":"https://api.github.com/repos/iclanzan/react-motion/assignees{/user}","branches_url":"https://api.github.com/repos/iclanzan/react-motion/branches{/branch}","tags_url":"https://api.github.com/repos/iclanzan/react-motion/tags","blobs_url":"https://api.github.com/repos/iclanzan/react-motion/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iclanzan/react-motion/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iclanzan/react-motion/git/refs{/sha}","trees_url":"https://api.github.com/repos/iclanzan/react-motion/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iclanzan/react-motion/statuses/{sha}","languages_url":"https://api.github.com/repos/iclanzan/react-motion/languages","stargazers_url":"https://api.github.com/repos/iclanzan/react-motion/stargazers","contributors_url":"https://api.github.com/repos/iclanzan/react-motion/contributors","subscribers_url":"https://api.github.com/repos/iclanzan/react-motion/subscribers","subscription_url":"https://api.github.com/repos/iclanzan/react-motion/subscription","commits_url":"https://api.github.com/repos/iclanzan/react-motion/commits{/sha}","git_commits_url":"https://api.github.com/repos/iclanzan/react-motion/git/commits{/sha}","comments_url":"https://api.github.com/repos/iclanzan/react-motion/comments{/number}","issue_comment_url":"https://api.github.com/repos/iclanzan/react-motion/issues/comments{/number}","contents_url":"https://api.github.com/repos/iclanzan/react-motion/contents/{+path}","compare_url":"https://api.github.com/repos/iclanzan/react-motion/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iclanzan/react-motion/merges","archive_url":"https://api.github.com/repos/iclanzan/react-motion/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iclanzan/react-motion/downloads","issues_url":"https://api.github.com/repos/iclanzan/react-motion/issues{/number}","pulls_url":"https://api.github.com/repos/iclanzan/react-motion/pulls{/number}","milestones_url":"https://api.github.com/repos/iclanzan/react-motion/milestones{/number}","notifications_url":"https://api.github.com/repos/iclanzan/react-motion/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iclanzan/react-motion/labels{/name}","releases_url":"https://api.github.com/repos/iclanzan/react-motion/releases{/id}","created_at":"2015-07-10T19:57:07Z","updated_at":"2015-07-10T19:57:07Z","pushed_at":"2015-07-12T21:39:58Z","git_url":"git://github.com/iclanzan/react-motion.git","ssh_url":"git@github.com:iclanzan/react-motion.git","clone_url":"https://github.com/iclanzan/react-motion.git","svn_url":"https://github.com/iclanzan/react-motion","homepage":"","size":966,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"chenglou:master","ref":"master","sha":"c98955f2b04cab7c27341d6fc784ad779f2e1fdb","user":{"login":"chenglou","id":1909539,"avatar_url":"https://avatars.githubusercontent.com/u/1909539?v=3","gravatar_id":"","url":"https://api.github.com/users/chenglou","html_url":"https://github.com/chenglou","followers_url":"https://api.github.com/users/chenglou/followers","following_url":"https://api.github.com/users/chenglou/following{/other_user}","gists_url":"https://api.github.com/users/chenglou/gists{/gist_id}","starred_url":"https://api.github.com/users/chenglou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chenglou/subscriptions","organizations_url":"https://api.github.com/users/chenglou/orgs","repos_url":"https://api.github.com/users/chenglou/repos","events_url":"https://api.github.com/users/chenglou/events{/privacy}","received_events_url":"https://api.github.com/users/chenglou/received_events","type":"User","site_admin":false},"repo":{"id":37246537,"name":"react-motion","full_name":"chenglou/react-motion","owner":{"login":"chenglou","id":1909539,"avatar_url":"https://avatars.githubusercontent.com/u/1909539?v=3","gravatar_id":"","url":"https://api.github.com/users/chenglou","html_url":"https://github.com/chenglou","followers_url":"https://api.github.com/users/chenglou/followers","following_url":"https://api.github.com/users/chenglou/following{/other_user}","gists_url":"https://api.github.com/users/chenglou/gists{/gist_id}","starred_url":"https://api.github.com/users/chenglou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chenglou/subscriptions","organizations_url":"https://api.github.com/users/chenglou/orgs","repos_url":"https://api.github.com/users/chenglou/repos","events_url":"https://api.github.com/users/chenglou/events{/privacy}","received_events_url":"https://api.github.com/users/chenglou/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chenglou/react-motion","description":"A spring that solves your animation problems.","fork":false,"url":"https://api.github.com/repos/chenglou/react-motion","forks_url":"https://api.github.com/repos/chenglou/react-motion/forks","keys_url":"https://api.github.com/repos/chenglou/react-motion/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chenglou/react-motion/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chenglou/react-motion/teams","hooks_url":"https://api.github.com/repos/chenglou/react-motion/hooks","issue_events_url":"https://api.github.com/repos/chenglou/react-motion/issues/events{/number}","events_url":"https://api.github.com/repos/chenglou/react-motion/events","assignees_url":"https://api.github.com/repos/chenglou/react-motion/assignees{/user}","branches_url":"https://api.github.com/repos/chenglou/react-motion/branches{/branch}","tags_url":"https://api.github.com/repos/chenglou/react-motion/tags","blobs_url":"https://api.github.com/repos/chenglou/react-motion/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chenglou/react-motion/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chenglou/react-motion/git/refs{/sha}","trees_url":"https://api.github.com/repos/chenglou/react-motion/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chenglou/react-motion/statuses/{sha}","languages_url":"https://api.github.com/repos/chenglou/react-motion/languages","stargazers_url":"https://api.github.com/repos/chenglou/react-motion/stargazers","contributors_url":"https://api.github.com/repos/chenglou/react-motion/contributors","subscribers_url":"https://api.github.com/repos/chenglou/react-motion/subscribers","subscription_url":"https://api.github.com/repos/chenglou/react-motion/subscription","commits_url":"https://api.github.com/repos/chenglou/react-motion/commits{/sha}","git_commits_url":"https://api.github.com/repos/chenglou/react-motion/git/commits{/sha}","comments_url":"https://api.github.com/repos/chenglou/react-motion/comments{/number}","issue_comment_url":"https://api.github.com/repos/chenglou/react-motion/issues/comments{/number}","contents_url":"https://api.github.com/repos/chenglou/react-motion/contents/{+path}","compare_url":"https://api.github.com/repos/chenglou/react-motion/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chenglou/react-motion/merges","archive_url":"https://api.github.com/repos/chenglou/react-motion/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chenglou/react-motion/downloads","issues_url":"https://api.github.com/repos/chenglou/react-motion/issues{/number}","pulls_url":"https://api.github.com/repos/chenglou/react-motion/pulls{/number}","milestones_url":"https://api.github.com/repos/chenglou/react-motion/milestones{/number}","notifications_url":"https://api.github.com/repos/chenglou/react-motion/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chenglou/react-motion/labels{/name}","releases_url":"https://api.github.com/repos/chenglou/react-motion/releases{/id}","created_at":"2015-06-11T07:38:23Z","updated_at":"2015-07-12T22:16:36Z","pushed_at":"2015-07-12T21:45:52Z","git_url":"git://github.com/chenglou/react-motion.git","ssh_url":"git@github.com:chenglou/react-motion.git","clone_url":"https://github.com/chenglou/react-motion.git","svn_url":"https://github.com/chenglou/react-motion","homepage":"","size":1610,"stargazers_count":923,"watchers_count":923,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":32,"mirror_url":null,"open_issues_count":18,"forks":32,"open_issues":18,"watchers":923,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/chenglou/react-motion/pulls/57"},"html":{"href":"https://github.com/chenglou/react-motion/pull/57"},"issue":{"href":"https://api.github.com/repos/chenglou/react-motion/issues/57"},"comments":{"href":"https://api.github.com/repos/chenglou/react-motion/issues/57/comments"},"review_comments":{"href":"https://api.github.com/repos/chenglou/react-motion/pulls/57/comments"},"review_comment":{"href":"https://api.github.com/repos/chenglou/react-motion/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/chenglou/react-motion/pulls/57/commits"},"statuses":{"href":"https://api.github.com/repos/chenglou/react-motion/statuses/2877c7f91cfc50bf28e50bdf32d545ae794fe144"}}}}