From ce30f9a6b5df5912470e0aa9d6f12c68b7ce398a Mon Sep 17 00:00:00 2001 From: sveisvei Date: Sat, 17 Dec 2016 19:49:31 +0100 Subject: [PATCH] remove semiease and set back to 5s animation --- .../component/feature/progress-styles.scss | 2 +- frontend/src/component/feature/progress.jsx | 25 +++++++------------ 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/frontend/src/component/feature/progress-styles.scss b/frontend/src/component/feature/progress-styles.scss index c3a79c7de9..b7a00a2a1b 100644 --- a/frontend/src/component/feature/progress-styles.scss +++ b/frontend/src/component/feature/progress-styles.scss @@ -1,7 +1,7 @@ .path { stroke: #3f51b5; stroke-linecap: round; - transition: stroke-dashoffset 11s ease 0s; + transition: stroke-dashoffset 5s ease 0s; } .trail { diff --git a/frontend/src/component/feature/progress.jsx b/frontend/src/component/feature/progress.jsx index c5b67fb3fd..a5f3213704 100644 --- a/frontend/src/component/feature/progress.jsx +++ b/frontend/src/component/feature/progress.jsx @@ -1,5 +1,11 @@ import React, { PropTypes, Component } from 'react'; import styles from './progress-styles.scss'; +import easing from 'bezier-easing'; + +const fn = easing(0, 0, 1, 0.5); + +window.easing = easing; +// console.log(s); class Progress extends Component { constructor (props) { @@ -37,30 +43,17 @@ class Progress extends Component { getTarget (target) { const start = this.state.percentageText; - const TOTAL_ANIMATION_TIME = 10000; + const TOTAL_ANIMATION_TIME = 5000; const diff = start > target ? -(start - target) : target - start; const perCycle = TOTAL_ANIMATION_TIME / diff; const cyclesCounter = Math.round(Math.abs(TOTAL_ANIMATION_TIME / perCycle)); const perCycleTime = Math.round(Math.abs(perCycle)); - let usedTime = 0; - // this initial value could be tweaked more - let lastTime = perCycleTime / 4; return { start, target, cyclesCounter, - getTimer () { - /* Somewhat tweaked values to get a curve on the counting */ - if (usedTime > (TOTAL_ANIMATION_TIME / 2)) { - // if halfway, lets speed up timeouts - lastTime *= 0.95; - } else { - lastTime *= 1.1; - } - usedTime += lastTime; - return lastTime; - }, + perCycleTime, increment: diff / cyclesCounter, }; } @@ -82,7 +75,7 @@ class Progress extends Component { this.setState({ percentageText: next }); this.nextTimer = setTimeout(() => { this.animateTo(next, targetState); - }, targetState.getTimer()); + }, targetState.perCycleTime); }); }