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

Unified Diff: sky/framework/fling-curve.sky

Issue 950603002: Port sky-scrollable to Dart (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: less setAttributes Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/framework/fling-curve.dart ('k') | sky/framework/sky-element.sky » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/framework/fling-curve.sky
diff --git a/sky/framework/fling-curve.sky b/sky/framework/fling-curve.sky
deleted file mode 100644
index 1c13908b4f974ad9427238b977794ed67dc1e1ad..0000000000000000000000000000000000000000
--- a/sky/framework/fling-curve.sky
+++ /dev/null
@@ -1,47 +0,0 @@
-<!--
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
--->
-<script>
-const kDefaultAlpha = -5707.62;
-const kDefaultBeta = 172;
-const kDefaultGamma = 3.7;
-
-function positionAtTime(t) {
- return kDefaultAlpha * Math.exp(-kDefaultGamma * t) - kDefaultBeta * t - kDefaultAlpha;
-}
-
-function velocityAtTime(t) {
- return -kDefaultAlpha * kDefaultGamma * Math.exp(-kDefaultGamma * t) - kDefaultBeta;
-}
-
-function timeAtVelocity(v) {
- return -Math.log((v + kDefaultBeta) / (-kDefaultAlpha * kDefaultGamma)) / kDefaultGamma;
-}
-
-var kMaxVelocity = velocityAtTime(0);
-var kCurveDuration = timeAtVelocity(0);
-
-module.exports = class FlingCurve {
- constructor(velocity, startTime) {
- var startingVelocity = Math.min(kMaxVelocity, Math.abs(velocity));
- this.timeOffset_ = timeAtVelocity(startingVelocity);
- this.positionOffset_ = positionAtTime(this.timeOffset_);
- this.startTime_ = startTime / 1000;
- this.previousPosition_ = 0;
- this.direction_ = Math.sign(velocity);
- Object.preventExtensions(this);
- }
-
- update(timeStamp) {
- var t = timeStamp / 1000 - this.startTime_ + this.timeOffset_;
- if (t >= kCurveDuration)
- return 0;
- var position = positionAtTime(t) - this.positionOffset_;
- var positionDelta = position - this.previousPosition_;
- this.previousPosition_ = position;
- return this.direction_ * Math.max(0, positionDelta);
- }
-};
-</script>
« no previous file with comments | « sky/framework/fling-curve.dart ('k') | sky/framework/sky-element.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698