{"action":"created","comment":{"url":"https://api.github.com/repos/angular/angular/pulls/comments/38496028","id":38496028,"diff_hunk":"@@ -0,0 +1,187 @@\n+import {\n+  DateWrapper,\n+  StringWrapper,\n+  RegExpWrapper,\n+  NumberWrapper\n+} from 'angular2/src/core/facade/lang';\n+import {Math} from 'angular2/src/core/facade/math';\n+import {camelCaseToDashCase} from 'angular2/src/core/render/dom/util';\n+import {StringMapWrapper} from 'angular2/src/core/facade/collection';\n+import {DOM} from 'angular2/src/core/dom/dom_adapter';\n+\n+import {AnimateHelpers} from './animate_helpers';\n+import {AnimateCssOptions} from './animate_css_options';\n+import {RAF} from './raf';\n+\n+export class AnimateRunner {\n+  /** functions to be called upon completion */\n+  callbacks: Function[] = [];\n+\n+  /** the duration (ms) of the animation (whether from CSS or manually set) */\n+  computedDuration: number;\n+\n+  /** the animation delay (ms) (whether from CSS or manually set) */\n+  computedDelay: number;\n+\n+  /** timestamp of when the animation started */\n+  startTime: number;\n+\n+  /** functions for removing event listeners */\n+  eventFns: Function[] = [];\n+\n+  /** flag used to track whether or not the animation has finished */\n+  completed: boolean = false;\n+\n+  /** total amount of time that the animation should take including delay */\n+  get totalTime(): number {\n+    let delay = this.computedDelay != null ? this.computedDelay : 0;\n+    let duration = this.computedDuration != null ? this.computedDuration : 0;\n+    return delay + duration;\n+  }\n+\n+  /**\n+   * Stores the start time and starts the animation\n+   * @param element\n+   * @param data\n+   * @param raf\n+   * @param helpers\n+   */\n+  constructor(public element: HTMLElement, public data: AnimateCssOptions, public raf: RAF,\n+              public helpers: AnimateHelpers) {\n+    this.startTime = DateWrapper.toMillis(DateWrapper.now());\n+    this.setup();\n+    // Firefox requires 2 frames for some reason\n+    raf.create(timestamp => this.start(), 2);\n+  }\n+\n+  /**\n+   * Sets up the initial styles before the animation is started\n+   */\n+  setup(): void {\n+    if (this.data.fromStyles != null) this.applyStyles(this.data.fromStyles);\n+    if (this.data.duration != null)\n+      this.applyStyles({'transitionDuration': this.data.duration.toString() + 'ms'});\n+    if (this.data.delay != null)\n+      this.applyStyles({'transitionDelay': this.data.delay.toString() + 'ms'});\n+  }\n+\n+  /**\n+   * After the initial setup has occurred, this method adds the animation styles\n+   */\n+  start(): void {\n+    this.addClasses(this.data.classesToAdd);\n+    this.addClasses(this.data.temporaryClasses);\n+    this.removeClasses(this.data.classesToRemove);\n+    if (this.data.toStyles != null) this.applyStyles(this.data.toStyles);\n+    var computedStyles = DOM.getComputedStyle(this.element);\n+    this.computedDelay = Math.max(\n+        AnimateRunner.parseDurationString(computedStyles.getPropertyValue('transition-delay')),\n+        AnimateRunner.parseDurationString(this.element.style.getPropertyValue('transition-delay')));\n+    this.computedDuration = Math.max(\n+        AnimateRunner.parseDurationString(computedStyles.getPropertyValue('transition-duration')),\n+        AnimateRunner.parseDurationString(\n+            this.element.style.getPropertyValue('transition-duration')));\n+    this.addEvents();\n+  }\n+\n+  /**\n+   * Applies the provided styles to the element\n+   * @param styles\n+   */\n+  applyStyles(styles: StringMap<string, any>): void {\n+    StringMapWrapper.forEach(styles, (value, key) => {\n+      DOM.setStyle(this.element, camelCaseToDashCase(key), value.toString());\n+    });\n+  }\n+\n+  /**\n+   * Adds the provided classes to the element\n+   * @param classes\n+   */\n+  addClasses(classes: string[]): void {\n+    classes.forEach(className => DOM.addClass(this.element, className));\n+  }\n+\n+  /**\n+   * Removes the provided classes from the element\n+   * @param classes\n+   */\n+  removeClasses(classes: string[]): void {\n+    classes.forEach(className => DOM.removeClass(this.element, className));\n+  }\n+\n+  /**\n+   * Adds events to track when animations have finished\n+   */\n+  addEvents(): void {\n+    if (this.totalTime > 0) {\n+      this.eventFns.push(DOM.onAndCancel(this.element, 'transitionend',\n+                                         (event: any) => this.handleAnimationEvent(event)));\n+    } else {\n+      this.handleAnimationCompleted();\n+    }\n+  }\n+\n+  handleAnimationEvent(event: any): void {\n+    let elapsedTime = Math.round(event.elapsedTime * 1000);\n+    if (!this.helpers.ELAPSED_TIME_INCLUDES_DELAY) elapsedTime += this.computedDelay;\n+    event.stopPropagation();\n+    if (elapsedTime >= this.totalTime) this.handleAnimationCompleted();\n+  }\n+\n+  /**\n+   * Runs all animation callbacks and removes temporary classes\n+   */\n+  handleAnimationCompleted(): void {","path":"modules/angular2/src/animate/animate_runner.ts","position":135,"original_position":135,"commit_id":"76fcf0c7d4d49171dbb66e7d558b7cb3df6445b0","original_commit_id":"76fcf0c7d4d49171dbb66e7d558b7cb3df6445b0","user":{"login":"robertmesserle","id":571363,"avatar_url":"https://avatars.githubusercontent.com/u/571363?v=3","gravatar_id":"","url":"https://api.github.com/users/robertmesserle","html_url":"https://github.com/robertmesserle","followers_url":"https://api.github.com/users/robertmesserle/followers","following_url":"https://api.github.com/users/robertmesserle/following{/other_user}","gists_url":"https://api.github.com/users/robertmesserle/gists{/gist_id}","starred_url":"https://api.github.com/users/robertmesserle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertmesserle/subscriptions","organizations_url":"https://api.github.com/users/robertmesserle/orgs","repos_url":"https://api.github.com/users/robertmesserle/repos","events_url":"https://api.github.com/users/robertmesserle/events{/privacy}","received_events_url":"https://api.github.com/users/robertmesserle/received_events","type":"User","site_admin":false},"body":"Is there a way to make this private, but still be able to access it for unit testing?","created_at":"2015-09-02T03:21:51Z","updated_at":"2015-09-02T03:21:51Z","html_url":"https://github.com/angular/angular/pull/3876#discussion_r38496028","pull_request_url":"https://api.github.com/repos/angular/angular/pulls/3876","_links":{"self":{"href":"https://api.github.com/repos/angular/angular/pulls/comments/38496028"},"html":{"href":"https://github.com/angular/angular/pull/3876#discussion_r38496028"},"pull_request":{"href":"https://api.github.com/repos/angular/angular/pulls/3876"}}},"pull_request":{"url":"https://api.github.com/repos/angular/angular/pulls/3876","id":43565226,"html_url":"https://github.com/angular/angular/pull/3876","diff_url":"https://github.com/angular/angular/pull/3876.diff","patch_url":"https://github.com/angular/angular/pull/3876.patch","issue_url":"https://api.github.com/repos/angular/angular/issues/3876","number":3876,"state":"open","locked":false,"title":"Adds Animate service and enter/leave CSS hooks","user":{"login":"robertmesserle","id":571363,"avatar_url":"https://avatars.githubusercontent.com/u/571363?v=3","gravatar_id":"","url":"https://api.github.com/users/robertmesserle","html_url":"https://github.com/robertmesserle","followers_url":"https://api.github.com/users/robertmesserle/followers","following_url":"https://api.github.com/users/robertmesserle/following{/other_user}","gists_url":"https://api.github.com/users/robertmesserle/gists{/gist_id}","starred_url":"https://api.github.com/users/robertmesserle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertmesserle/subscriptions","organizations_url":"https://api.github.com/users/robertmesserle/orgs","repos_url":"https://api.github.com/users/robertmesserle/repos","events_url":"https://api.github.com/users/robertmesserle/events{/privacy}","received_events_url":"https://api.github.com/users/robertmesserle/received_events","type":"User","site_admin":false},"body":"- Users can animate CSS via Animate.prototype.css()\r\n- Adds temporary hooks (`ng-enter`, `ng-leave`) for CSS animations","created_at":"2015-08-27T20:51:03Z","updated_at":"2015-09-02T03:21:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3cce4a817df09788eb0e07cdd78acd0828b7fde1","assignee":{"login":"robertmesserle","id":571363,"avatar_url":"https://avatars.githubusercontent.com/u/571363?v=3","gravatar_id":"","url":"https://api.github.com/users/robertmesserle","html_url":"https://github.com/robertmesserle","followers_url":"https://api.github.com/users/robertmesserle/followers","following_url":"https://api.github.com/users/robertmesserle/following{/other_user}","gists_url":"https://api.github.com/users/robertmesserle/gists{/gist_id}","starred_url":"https://api.github.com/users/robertmesserle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertmesserle/subscriptions","organizations_url":"https://api.github.com/users/robertmesserle/orgs","repos_url":"https://api.github.com/users/robertmesserle/repos","events_url":"https://api.github.com/users/robertmesserle/events{/privacy}","received_events_url":"https://api.github.com/users/robertmesserle/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/angular/angular/pulls/3876/commits","review_comments_url":"https://api.github.com/repos/angular/angular/pulls/3876/comments","review_comment_url":"https://api.github.com/repos/angular/angular/pulls/comments{/number}","comments_url":"https://api.github.com/repos/angular/angular/issues/3876/comments","statuses_url":"https://api.github.com/repos/angular/angular/statuses/76fcf0c7d4d49171dbb66e7d558b7cb3df6445b0","head":{"label":"robertmesserle:wip/animate-css","ref":"wip/animate-css","sha":"76fcf0c7d4d49171dbb66e7d558b7cb3df6445b0","user":{"login":"robertmesserle","id":571363,"avatar_url":"https://avatars.githubusercontent.com/u/571363?v=3","gravatar_id":"","url":"https://api.github.com/users/robertmesserle","html_url":"https://github.com/robertmesserle","followers_url":"https://api.github.com/users/robertmesserle/followers","following_url":"https://api.github.com/users/robertmesserle/following{/other_user}","gists_url":"https://api.github.com/users/robertmesserle/gists{/gist_id}","starred_url":"https://api.github.com/users/robertmesserle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertmesserle/subscriptions","organizations_url":"https://api.github.com/users/robertmesserle/orgs","repos_url":"https://api.github.com/users/robertmesserle/repos","events_url":"https://api.github.com/users/robertmesserle/events{/privacy}","received_events_url":"https://api.github.com/users/robertmesserle/received_events","type":"User","site_admin":false},"repo":{"id":41107466,"name":"angular","full_name":"robertmesserle/angular","owner":{"login":"robertmesserle","id":571363,"avatar_url":"https://avatars.githubusercontent.com/u/571363?v=3","gravatar_id":"","url":"https://api.github.com/users/robertmesserle","html_url":"https://github.com/robertmesserle","followers_url":"https://api.github.com/users/robertmesserle/followers","following_url":"https://api.github.com/users/robertmesserle/following{/other_user}","gists_url":"https://api.github.com/users/robertmesserle/gists{/gist_id}","starred_url":"https://api.github.com/users/robertmesserle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertmesserle/subscriptions","organizations_url":"https://api.github.com/users/robertmesserle/orgs","repos_url":"https://api.github.com/users/robertmesserle/repos","events_url":"https://api.github.com/users/robertmesserle/events{/privacy}","received_events_url":"https://api.github.com/users/robertmesserle/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/robertmesserle/angular","description":"","fork":true,"url":"https://api.github.com/repos/robertmesserle/angular","forks_url":"https://api.github.com/repos/robertmesserle/angular/forks","keys_url":"https://api.github.com/repos/robertmesserle/angular/keys{/key_id}","collaborators_url":"https://api.github.com/repos/robertmesserle/angular/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/robertmesserle/angular/teams","hooks_url":"https://api.github.com/repos/robertmesserle/angular/hooks","issue_events_url":"https://api.github.com/repos/robertmesserle/angular/issues/events{/number}","events_url":"https://api.github.com/repos/robertmesserle/angular/events","assignees_url":"https://api.github.com/repos/robertmesserle/angular/assignees{/user}","branches_url":"https://api.github.com/repos/robertmesserle/angular/branches{/branch}","tags_url":"https://api.github.com/repos/robertmesserle/angular/tags","blobs_url":"https://api.github.com/repos/robertmesserle/angular/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/robertmesserle/angular/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/robertmesserle/angular/git/refs{/sha}","trees_url":"https://api.github.com/repos/robertmesserle/angular/git/trees{/sha}","statuses_url":"https://api.github.com/repos/robertmesserle/angular/statuses/{sha}","languages_url":"https://api.github.com/repos/robertmesserle/angular/languages","stargazers_url":"https://api.github.com/repos/robertmesserle/angular/stargazers","contributors_url":"https://api.github.com/repos/robertmesserle/angular/contributors","subscribers_url":"https://api.github.com/repos/robertmesserle/angular/subscribers","subscription_url":"https://api.github.com/repos/robertmesserle/angular/subscription","commits_url":"https://api.github.com/repos/robertmesserle/angular/commits{/sha}","git_commits_url":"https://api.github.com/repos/robertmesserle/angular/git/commits{/sha}","comments_url":"https://api.github.com/repos/robertmesserle/angular/comments{/number}","issue_comment_url":"https://api.github.com/repos/robertmesserle/angular/issues/comments{/number}","contents_url":"https://api.github.com/repos/robertmesserle/angular/contents/{+path}","compare_url":"https://api.github.com/repos/robertmesserle/angular/compare/{base}...{head}","merges_url":"https://api.github.com/repos/robertmesserle/angular/merges","archive_url":"https://api.github.com/repos/robertmesserle/angular/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/robertmesserle/angular/downloads","issues_url":"https://api.github.com/repos/robertmesserle/angular/issues{/number}","pulls_url":"https://api.github.com/repos/robertmesserle/angular/pulls{/number}","milestones_url":"https://api.github.com/repos/robertmesserle/angular/milestones{/number}","notifications_url":"https://api.github.com/repos/robertmesserle/angular/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/robertmesserle/angular/labels{/name}","releases_url":"https://api.github.com/repos/robertmesserle/angular/releases{/id}","created_at":"2015-08-20T16:45:23Z","updated_at":"2015-08-20T16:45:26Z","pushed_at":"2015-09-01T18:12:14Z","git_url":"git://github.com/robertmesserle/angular.git","ssh_url":"git@github.com:robertmesserle/angular.git","clone_url":"https://github.com/robertmesserle/angular.git","svn_url":"https://github.com/robertmesserle/angular","homepage":"https://angular.io","size":13381,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","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":"angular:master","ref":"master","sha":"42e1b077051be4ef2fc8694b3aedf330973d53eb","user":{"login":"angular","id":139426,"avatar_url":"https://avatars.githubusercontent.com/u/139426?v=3","gravatar_id":"","url":"https://api.github.com/users/angular","html_url":"https://github.com/angular","followers_url":"https://api.github.com/users/angular/followers","following_url":"https://api.github.com/users/angular/following{/other_user}","gists_url":"https://api.github.com/users/angular/gists{/gist_id}","starred_url":"https://api.github.com/users/angular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angular/subscriptions","organizations_url":"https://api.github.com/users/angular/orgs","repos_url":"https://api.github.com/users/angular/repos","events_url":"https://api.github.com/users/angular/events{/privacy}","received_events_url":"https://api.github.com/users/angular/received_events","type":"Organization","site_admin":false},"repo":{"id":24195339,"name":"angular","full_name":"angular/angular","owner":{"login":"angular","id":139426,"avatar_url":"https://avatars.githubusercontent.com/u/139426?v=3","gravatar_id":"","url":"https://api.github.com/users/angular","html_url":"https://github.com/angular","followers_url":"https://api.github.com/users/angular/followers","following_url":"https://api.github.com/users/angular/following{/other_user}","gists_url":"https://api.github.com/users/angular/gists{/gist_id}","starred_url":"https://api.github.com/users/angular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angular/subscriptions","organizations_url":"https://api.github.com/users/angular/orgs","repos_url":"https://api.github.com/users/angular/repos","events_url":"https://api.github.com/users/angular/events{/privacy}","received_events_url":"https://api.github.com/users/angular/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/angular/angular","description":"","fork":false,"url":"https://api.github.com/repos/angular/angular","forks_url":"https://api.github.com/repos/angular/angular/forks","keys_url":"https://api.github.com/repos/angular/angular/keys{/key_id}","collaborators_url":"https://api.github.com/repos/angular/angular/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/angular/angular/teams","hooks_url":"https://api.github.com/repos/angular/angular/hooks","issue_events_url":"https://api.github.com/repos/angular/angular/issues/events{/number}","events_url":"https://api.github.com/repos/angular/angular/events","assignees_url":"https://api.github.com/repos/angular/angular/assignees{/user}","branches_url":"https://api.github.com/repos/angular/angular/branches{/branch}","tags_url":"https://api.github.com/repos/angular/angular/tags","blobs_url":"https://api.github.com/repos/angular/angular/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/angular/angular/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/angular/angular/git/refs{/sha}","trees_url":"https://api.github.com/repos/angular/angular/git/trees{/sha}","statuses_url":"https://api.github.com/repos/angular/angular/statuses/{sha}","languages_url":"https://api.github.com/repos/angular/angular/languages","stargazers_url":"https://api.github.com/repos/angular/angular/stargazers","contributors_url":"https://api.github.com/repos/angular/angular/contributors","subscribers_url":"https://api.github.com/repos/angular/angular/subscribers","subscription_url":"https://api.github.com/repos/angular/angular/subscription","commits_url":"https://api.github.com/repos/angular/angular/commits{/sha}","git_commits_url":"https://api.github.com/repos/angular/angular/git/commits{/sha}","comments_url":"https://api.github.com/repos/angular/angular/comments{/number}","issue_comment_url":"https://api.github.com/repos/angular/angular/issues/comments{/number}","contents_url":"https://api.github.com/repos/angular/angular/contents/{+path}","compare_url":"https://api.github.com/repos/angular/angular/compare/{base}...{head}","merges_url":"https://api.github.com/repos/angular/angular/merges","archive_url":"https://api.github.com/repos/angular/angular/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/angular/angular/downloads","issues_url":"https://api.github.com/repos/angular/angular/issues{/number}","pulls_url":"https://api.github.com/repos/angular/angular/pulls{/number}","milestones_url":"https://api.github.com/repos/angular/angular/milestones{/number}","notifications_url":"https://api.github.com/repos/angular/angular/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/angular/angular/labels{/name}","releases_url":"https://api.github.com/repos/angular/angular/releases{/id}","created_at":"2014-09-18T16:12:01Z","updated_at":"2015-09-02T02:31:46Z","pushed_at":"2015-09-02T02:48:15Z","git_url":"git://github.com/angular/angular.git","ssh_url":"git@github.com:angular/angular.git","clone_url":"https://github.com/angular/angular.git","svn_url":"https://github.com/angular/angular","homepage":"https://angular.io","size":48415,"stargazers_count":5093,"watchers_count":5093,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1352,"mirror_url":null,"open_issues_count":402,"forks":1352,"open_issues":402,"watchers":5093,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/angular/angular/pulls/3876"},"html":{"href":"https://github.com/angular/angular/pull/3876"},"issue":{"href":"https://api.github.com/repos/angular/angular/issues/3876"},"comments":{"href":"https://api.github.com/repos/angular/angular/issues/3876/comments"},"review_comments":{"href":"https://api.github.com/repos/angular/angular/pulls/3876/comments"},"review_comment":{"href":"https://api.github.com/repos/angular/angular/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/angular/angular/pulls/3876/commits"},"statuses":{"href":"https://api.github.com/repos/angular/angular/statuses/76fcf0c7d4d49171dbb66e7d558b7cb3df6445b0"}}}}