Skip to content

Commit

Permalink
Merge branch 'master' into typescript
Browse files Browse the repository at this point in the history
* master: (38 commits)
  update dist files
  rename some tests to better reflect what they test
  improve the conditional logic more so that values in nested arrays can also be animated
  add and example and test for animating values in an array
  start values aren't arrays, only to values are
  move _updateProperties function back out to a method
  fix yoyo with array values test
  temporary, move updateProperties function to make diff with master more clear
  move some code and update variable names to make mergin with master easier (less conflict)
  update dist
  improve state reset when stopping and starting a tween (fixes #512 where yoyo wouldn't restart properly)
  move value-swapping code for repeated tweens to a function (it will be re-used in an upcoming change)
  consolidate duplicate handling of relative values
  update dist files
  ignore VS Code's config folder
  small refactor to prevent update from doing anything when a tween has finished, yet still allow tweens to go back in time
  fix lint error
  rename _isFinished to _isComplete to match other wording
  add one more test for relative array values
  add editorconfig to settings editors can be consistently unique (because we use tabs so people can set their own tab width)
  ...
  • Loading branch information
trusktr committed Jun 3, 2020
2 parents 8b87aed + f65c82a commit 899a0e3
Show file tree
Hide file tree
Showing 42 changed files with 3,059 additions and 1,855 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
charset = utf-8
indent_style = tab
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
indent_size = 2
indent_style = space
14 changes: 7 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.DS_Store
.idea
.vscode
.tmp
build/npm*
node_modules
npm-debug.log
.DS_Store
.idea
.vscode
.tmp
build/npm*
node_modules
npm-debug.log
2 changes: 1 addition & 1 deletion README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var coords = {x: 0, y: 0} // 起始点 (0, 0)
var tween = new TWEEN.Tween(coords) // 创建一个新的tween用来改变 'coords'
.to({x: 300, y: 200}, 1000) // 在1s内移动至 (300, 200)
.easing(TWEEN.Easing.Quadratic.Out) // 使用缓动功能使的动画更加平滑
.onUpdate(function() {
.onUpdate(function () {
// 在 tween.js 更新 'coords' 后调用
// 将 'box' 移动到 'coords' 所描述的位置,配合 CSS 过渡
box.style.setProperty('transform', 'translate(' + coords.x + 'px, ' + coords.y + 'px)')
Expand Down
198 changes: 94 additions & 104 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,33 +61,7 @@ declare module "TWEEN" {
};
};

var NOW: () => number;

/**
* Basic representation of a Tween
*/
interface TweenBase {
playing: boolean;
update: (time: number) => boolean;
getId: () => number;
}

/**
* Controlling groups of tweens
*
* Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components.
* In these cases, you may want to create your own smaller groups of tween
*/
class Group {
private _tweens;
private _tweensAddedDuringUpdate;
constructor();
getAll(): TweenBase[];
removeAll(): void;
add(tween: TweenBase): void;
remove(tween: TweenBase): void;
update(time: number, preserve?: boolean): boolean;
}
let NOW: () => number;

/**
*
Expand All @@ -113,84 +87,11 @@ declare module "TWEEN" {
* Utils
*/
class Sequence {
static _nextId: number;
static nextId: () => number;
private static _nextId;
static nextId(): number;
}

/**
* A tween (from in-between) is a concept that allows you to change the values of the properties of an object in a
* smooth way. You just tell it which properties you want to change, which final values should they have when the
* tween finishes running, and how long should this take, and the tweening engine will take care of finding the
* intermediate values from the starting to the ending point.
*/
class Tween implements TweenBase {
static TWEEN: Group;
static inject(instance: Group): void;
playing: boolean;
private id;
private object;
private groupRef;
private paused;
private pauseStart;
private valuesStart;
private valuesEnd;
private valuesStartRepeat;
private durationValue;
private repeatValue;
private repeatDelayTime;
private yoyoValue;
private reversed;
private delayTime;
private startTime;
private easingFunction;
private interpolationFunction;
private chainedTweens;
private onStartCallbackFired;
private onStartCallback;
private onUpdateCallback;
private onRepeatCallback;
private onCompleteCallback;
private onStopCallback;
constructor(object: any, groupRef?: Group);
getId(): number;
isPlaying(): boolean;
isPaused(): boolean;
to(properties: {}, duration?: number): this;
duration(value: number): this;
start(time?: number | string): this;
stop(): this;
end(): this;
pause(time: number): this;
resume(time: number): this;
stopChainedTweens(): void;
group(group: Group): this;
delay(amount: number): this;
repeat(times: number): this;
repeatDelay(amount: number): this;
yoyo(yoyo: boolean): this;
easing(easing: EasingFunction): this;
interpolation(interpolation: InterpolationFunction): this;
chain(...tweens: Tween[]): this;
onStart(callback: (object: any) => void): this;
onUpdate(callback: (object: any, elapsed: number) => void): this;
onRepeat(callback: (object: any) => void): this;
onComplete(callback: (object: any) => void): this;
onStop(callback: (object: any) => void): this;

/**
* Tween.js doesn't run by itself. You need to tell it when to run, by explicitly calling the update method.
* The recommended method is to do this inside your main animation loop, which should be called with
* requestAnimationFrame for getting the best graphics performance
*
* If called without parameters, update will determine the current time in order to find out how long has it been
* since the last time it ran.
*
* @param time
*/
update(time?: number): boolean;
}

const VERSION = "18.6.0";
const VERSION = "18.5.0";

/**
* Controlling groups of tweens
Expand Down Expand Up @@ -268,12 +169,101 @@ declare module "TWEEN" {
CatmullRom: (p0: number, p1: number, p2: number, p3: number, t: number) => number;
};
};
nextId: () => number;
nextId: typeof Sequence.nextId;
Tween: typeof Tween;
}

const TWEEN: Main;

/**
* Tween.js - Licensed under the MIT license
* https://github.com/tweenjs/tween.js
* ----------------------------------------------
*
* See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors.
* Thank you all, you're awesome!
*/



class Tween<T extends UnknownProps> {
private _object;
private _group;
private _isPaused;
private _pauseStart;
private _valuesStart;
private _valuesEnd;
private _valuesStartRepeat;
private _duration;
private _initialRepeat;
private _repeat;
private _repeatDelayTime?;
private _yoyo;
private _isPlaying;
private _reversed;
private _delayTime;
private _startTime;
private _easingFunction;
private _interpolationFunction;
private _chainedTweens;
private _onStartCallback?;
private _onStartCallbackFired;
private _onUpdateCallback?;
private _onRepeatCallback?;
private _onCompleteCallback?;
private _onStopCallback?;
private _id;
private _isChainStopped;
constructor(_object: T, _group?: Group);
getId(): number;
isPlaying(): boolean;
isPaused(): boolean;
to(properties: UnknownProps, duration?: number): this;
duration(d: number): this;
start(time: number): this;
private _setupProperties;
stop(): this;
end(): this;
pause(time: number): this;
resume(time: number): this;
stopChainedTweens(): this;
group(group: Group): this;
delay(amount: number): this;
repeat(times: number): this;
repeatDelay(amount: number): this;
yoyo(yoyo: boolean): this;
easing(easingFunction: EasingFunction): this;
interpolation(interpolationFunction: InterpolationFunction): this;
chain(...tweens: Array<Tween<UnknownProps>>): this;
onStart(callback: (object: T) => void): this;
onUpdate(callback: (object: T, elapsed: number) => void): this;
onRepeat(callback: (object: T) => void): this;
onComplete(callback: (object: T) => void): this;
onStop(callback: (object: T) => void): this;
update(time: number): boolean;
private _updateProperties;
private _handleRelativeValue;
private _swapEndStartRepeatValues;
}

type UnknownProps = Record<string, unknown>;

/**
* Controlling groups of tweens
*
* Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components.
* In these cases, you may want to create your own smaller groups of tween
*/
class Group {
private _tweens;
private _tweensAddedDuringUpdate;
getAll(): Array<Tween<UnknownProps>>;
removeAll(): void;
add(tween: Tween<UnknownProps>): void;
remove(tween: Tween<UnknownProps>): void;
update(time: number, preserve?: boolean): boolean;
}

export default TWEEN;
}

Expand Down
Loading

0 comments on commit 899a0e3

Please sign in to comment.