mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-19 13:08:11 +08:00
Delay some requires in Animated
Reviewed By: sahrens Differential Revision: D3424476 fbshipit-source-id: 487835e310b7651e952f46991f2a64bc4967d58a
This commit is contained in:
committed by
Facebook Github Bot 6
parent
6210db8ffa
commit
482b4b6bfa
@@ -11,7 +11,6 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var Easing = require('Easing');
|
||||
var InteractionManager = require('InteractionManager');
|
||||
var Interpolation = require('Interpolation');
|
||||
var React = require('React');
|
||||
@@ -220,7 +219,14 @@ type TimingAnimationConfigSingle = AnimationConfig & {
|
||||
delay?: number;
|
||||
};
|
||||
|
||||
var easeInOut = Easing.inOut(Easing.ease);
|
||||
let _easeInOut;
|
||||
function easeInOut() {
|
||||
if (!_easeInOut) {
|
||||
const Easing = require('Easing');
|
||||
_easeInOut = Easing.inOut(Easing.ease);
|
||||
}
|
||||
return _easeInOut;
|
||||
}
|
||||
|
||||
class TimingAnimation extends Animation {
|
||||
_startTime: number;
|
||||
@@ -239,7 +245,7 @@ class TimingAnimation extends Animation {
|
||||
) {
|
||||
super();
|
||||
this._toValue = config.toValue;
|
||||
this._easing = config.easing !== undefined ? config.easing : easeInOut;
|
||||
this._easing = config.easing !== undefined ? config.easing : easeInOut();
|
||||
this._duration = config.duration !== undefined ? config.duration : 500;
|
||||
this._delay = config.delay !== undefined ? config.delay : 0;
|
||||
this.__isInteraction = config.isInteraction !== undefined ? config.isInteraction : true;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var _bezier = require('bezier');
|
||||
let ease;
|
||||
|
||||
/**
|
||||
* This class implements common easing functions. The math is pretty obscure,
|
||||
@@ -32,6 +32,9 @@ class Easing {
|
||||
}
|
||||
|
||||
static ease(t: number): number {
|
||||
if (!ease) {
|
||||
ease = Easing.bezier(0.42, 0, 1, 1);
|
||||
}
|
||||
return ease(t);
|
||||
}
|
||||
|
||||
@@ -70,7 +73,7 @@ class Easing {
|
||||
* http://tiny.cc/elastic_b_3 (bounciness = 3)
|
||||
*/
|
||||
static elastic(bounciness: number = 1): (t: number) => number {
|
||||
var p = bounciness * Math.PI;
|
||||
const p = bounciness * Math.PI;
|
||||
return (t) => 1 - Math.pow(Math.cos(t * Math.PI / 2), 3) * Math.cos(t * p);
|
||||
}
|
||||
|
||||
@@ -106,6 +109,7 @@ class Easing {
|
||||
x2: number,
|
||||
y2: number
|
||||
): (t: number) => number {
|
||||
const _bezier = require('bezier');
|
||||
return _bezier(x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
@@ -139,8 +143,4 @@ class Easing {
|
||||
}
|
||||
}
|
||||
|
||||
var ease = Easing.bezier(0.42, 0, 1, 1);
|
||||
|
||||
|
||||
|
||||
module.exports = Easing;
|
||||
|
||||
Reference in New Issue
Block a user