| OLD | NEW |
| 1 "use strict"; | 1 "use strict"; |
| 2 /* | 2 /* |
| 3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 } | 912 } |
| 913 | 913 |
| 914 AnimationManager.prototype = Object.create(EventEmitter.prototype); | 914 AnimationManager.prototype = Object.create(EventEmitter.prototype); |
| 915 | 915 |
| 916 AnimationManager.EventTypeAnimationFrameWillFinish = "animationFrameWillFinish"; | 916 AnimationManager.EventTypeAnimationFrameWillFinish = "animationFrameWillFinish"; |
| 917 | 917 |
| 918 AnimationManager.prototype._startAnimation = function() { | 918 AnimationManager.prototype._startAnimation = function() { |
| 919 if (this._isRunning) | 919 if (this._isRunning) |
| 920 return; | 920 return; |
| 921 this._isRunning = true; | 921 this._isRunning = true; |
| 922 window.webkitRequestAnimationFrame(this._animationFrameCallbackBound); | 922 window.requestAnimationFrame(this._animationFrameCallbackBound); |
| 923 }; | 923 }; |
| 924 | 924 |
| 925 AnimationManager.prototype._stopAnimation = function() { | 925 AnimationManager.prototype._stopAnimation = function() { |
| 926 if (!this._isRunning) | 926 if (!this._isRunning) |
| 927 return; | 927 return; |
| 928 this._isRunning = false; | 928 this._isRunning = false; |
| 929 }; | 929 }; |
| 930 | 930 |
| 931 /** | 931 /** |
| 932 * @param {!Animator} animator | 932 * @param {!Animator} animator |
| (...skipping 20 matching lines...) Expand all Loading... |
| 953 }; | 953 }; |
| 954 | 954 |
| 955 AnimationManager.prototype._animationFrameCallback = function(now) { | 955 AnimationManager.prototype._animationFrameCallback = function(now) { |
| 956 if (this._runningAnimatorCount > 0) { | 956 if (this._runningAnimatorCount > 0) { |
| 957 for (var id in this._runningAnimators) { | 957 for (var id in this._runningAnimators) { |
| 958 this._runningAnimators[id].onAnimationFrame(now); | 958 this._runningAnimators[id].onAnimationFrame(now); |
| 959 } | 959 } |
| 960 } | 960 } |
| 961 this.dispatchEvent(AnimationManager.EventTypeAnimationFrameWillFinish); | 961 this.dispatchEvent(AnimationManager.EventTypeAnimationFrameWillFinish); |
| 962 if (this._isRunning) | 962 if (this._isRunning) |
| 963 window.webkitRequestAnimationFrame(this._animationFrameCallbackBound); | 963 window.requestAnimationFrame(this._animationFrameCallbackBound); |
| 964 }; | 964 }; |
| 965 | 965 |
| 966 /** | 966 /** |
| 967 * @return {!boolean} | 967 * @return {!boolean} |
| 968 */ | 968 */ |
| 969 AnimationManager.prototype._needsTimer = function() { | 969 AnimationManager.prototype._needsTimer = function() { |
| 970 return this._runningAnimatorCount > 0 || this.hasListener(AnimationManager.E
ventTypeAnimationFrameWillFinish); | 970 return this._runningAnimatorCount > 0 || this.hasListener(AnimationManager.E
ventTypeAnimationFrameWillFinish); |
| 971 }; | 971 }; |
| 972 | 972 |
| 973 /** | 973 /** |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 Animator.EventTypeDidAnimationStop = "didAnimationStop"; | 1037 Animator.EventTypeDidAnimationStop = "didAnimationStop"; |
| 1038 | 1038 |
| 1039 /** | 1039 /** |
| 1040 * @return {!boolean} | 1040 * @return {!boolean} |
| 1041 */ | 1041 */ |
| 1042 Animator.prototype.isRunning = function() { | 1042 Animator.prototype.isRunning = function() { |
| 1043 return this._isRunning; | 1043 return this._isRunning; |
| 1044 }; | 1044 }; |
| 1045 | 1045 |
| 1046 Animator.prototype.start = function() { | 1046 Animator.prototype.start = function() { |
| 1047 this._lastStepTime = Date.now(); | 1047 this._lastStepTime = performance.now(); |
| 1048 this._isRunning = true; | 1048 this._isRunning = true; |
| 1049 AnimationManager.shared.add(this); | 1049 AnimationManager.shared.add(this); |
| 1050 }; | 1050 }; |
| 1051 | 1051 |
| 1052 Animator.prototype.stop = function() { | 1052 Animator.prototype.stop = function() { |
| 1053 if (!this._isRunning) | 1053 if (!this._isRunning) |
| 1054 return; | 1054 return; |
| 1055 this._isRunning = false; | 1055 this._isRunning = false; |
| 1056 AnimationManager.shared.remove(this); | 1056 AnimationManager.shared.remove(this); |
| 1057 this.dispatchEvent(Animator.EventTypeDidAnimationStop, this); | 1057 this.dispatchEvent(Animator.EventTypeDidAnimationStop, this); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1201 }; | 1201 }; |
| 1202 | 1202 |
| 1203 /** | 1203 /** |
| 1204 * @param {!number} v | 1204 * @param {!number} v |
| 1205 */ | 1205 */ |
| 1206 FlingGestureAnimator.prototype._timeAtVelocity = function(v) { | 1206 FlingGestureAnimator.prototype._timeAtVelocity = function(v) { |
| 1207 return -Math.log((v + FlingGestureAnimator._P1) / (-FlingGestureAnimator._P0
* FlingGestureAnimator._P2)) / FlingGestureAnimator._P2; | 1207 return -Math.log((v + FlingGestureAnimator._P1) / (-FlingGestureAnimator._P0
* FlingGestureAnimator._P2)) / FlingGestureAnimator._P2; |
| 1208 }; | 1208 }; |
| 1209 | 1209 |
| 1210 FlingGestureAnimator.prototype.start = function() { | 1210 FlingGestureAnimator.prototype.start = function() { |
| 1211 this._lastStepTime = Date.now(); | 1211 this._lastStepTime = performance.now(); |
| 1212 Animator.prototype.start.call(this); | 1212 Animator.prototype.start.call(this); |
| 1213 }; | 1213 }; |
| 1214 | 1214 |
| 1215 /** | 1215 /** |
| 1216 * @param {!number} now | 1216 * @param {!number} now |
| 1217 */ | 1217 */ |
| 1218 FlingGestureAnimator.prototype.onAnimationFrame = function(now) { | 1218 FlingGestureAnimator.prototype.onAnimationFrame = function(now) { |
| 1219 this._elapsedTime += now - this._lastStepTime; | 1219 this._elapsedTime += now - this._lastStepTime; |
| 1220 this._lastStepTime = now; | 1220 this._lastStepTime = now; |
| 1221 if (this._elapsedTime + this._timeOffset >= this.duration) { | 1221 if (this._elapsedTime + this._timeOffset >= this.duration) { |
| (...skipping 2816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4038 event.stopPropagation(); | 4038 event.stopPropagation(); |
| 4039 event.preventDefault(); | 4039 event.preventDefault(); |
| 4040 } | 4040 } |
| 4041 } | 4041 } |
| 4042 | 4042 |
| 4043 if (window.dialogArguments) { | 4043 if (window.dialogArguments) { |
| 4044 initialize(dialogArguments); | 4044 initialize(dialogArguments); |
| 4045 } else { | 4045 } else { |
| 4046 window.addEventListener("message", handleMessage, false); | 4046 window.addEventListener("message", handleMessage, false); |
| 4047 } | 4047 } |
| OLD | NEW |