Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.

Commit

Permalink
deprecate(Tween#seek): it not works as excepted, PR's are welcome for…
Browse files Browse the repository at this point in the history
… fix without loss (or less loss) of performance

config(change): change to latest
timing(repeat): now uses delayTime as repeatDelay for reducing config with more complexity
feat(startTime): now accepts relative timing
  • Loading branch information
dalisoft committed Sep 25, 2017
1 parent e851164 commit 15b6cde
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 95 deletions.
40 changes: 5 additions & 35 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ import {Tween} from 'es6-tween/src/Tween.Lite' let tween = new Tween({x:0}).to(
* [.stop()](#Lite+stop)
* [.delay(amount)](#Lite+delay)
* [.repeat(amount)](#Lite+repeat)
* [.repeatDelay(amount)](#Lite+repeatDelay)
* [.reverseDelay(amount)](#Lite+reverseDelay)
* [.yoyo(state)](#Lite+yoyo)
* [.easing(_easingFunction)](#Lite+easing)
Expand Down Expand Up @@ -483,21 +482,6 @@ Sets how times tween is repeating
```js
tween.repeat(2)
```
<a name="Lite+repeatDelay"></a>

### lite.repeatDelay(amount)
Set delay of each repeat of tween

**Kind**: instance method of [<code>Lite</code>](#Lite)

| Param | Type | Description |
| --- | --- | --- |
| amount | <code>number</code> | Sets tween repeat delay / repeat wait duration |

**Example**
```js
tween.repeatDelay(500)
```
<a name="Lite+reverseDelay"></a>

### lite.reverseDelay(amount)
Expand Down Expand Up @@ -703,14 +687,13 @@ let tween = new Tween(myNode, {width:'100px'}).to({width:'300px'}, 2000).start()
* [.pause()](#Tween+pause)
* [.play()](#Tween+play)
* [.restart([noDelay])](#Tween+restart)
* [.seek(time, [keepPlaying])](#Tween+seek)
* ~~[.seek(time, [keepPlaying])](#Tween+seek)~~
* [.duration(amount)](#Tween+duration)
* [.to(properties, [duration])](#Tween+to)
* [.start(time)](#Tween+start)
* [.stop()](#Tween+stop)
* [.delay(amount)](#Tween+delay)
* [.repeat(amount)](#Tween+repeat)
* [.repeatDelay(amount)](#Tween+repeatDelay)
* [.reverseDelay(amount)](#Tween+reverseDelay)
* [.yoyo(state, [_easingReverse])](#Tween+yoyo)
* [.easing(_easingFunction)](#Tween+easing)
Expand Down Expand Up @@ -799,8 +782,10 @@ tween.restart()
```
<a name="Tween+seek"></a>

### tween.seek(time, [keepPlaying])
Seek tween value by `time`
### ~~tween.seek(time, [keepPlaying])~~
***Deprecated***

Seek tween value by `time`. Note: Not works as excepted. PR are welcome

**Kind**: instance method of [<code>Tween</code>](#Tween)

Expand Down Expand Up @@ -899,21 +884,6 @@ Sets how times tween is repeating
```js
tween.repeat(5)
```
<a name="Tween+repeatDelay"></a>

### tween.repeatDelay(amount)
Set delay of each repeat of tween

**Kind**: instance method of [<code>Tween</code>](#Tween)

| Param | Type | Description |
| --- | --- | --- |
| amount | <code>number</code> | Sets tween repeat delay / repeat wait duration |

**Example**
```js
tween.repeatDelay(400)
```
<a name="Tween+reverseDelay"></a>

### tween.reverseDelay(amount)
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "es6-tween",
"version": "3.8.22",
"version": "3.8.23",
"description": "ES6 implementation of amazing tween.js",
"browser": "full/Tween.min.js",
"cdn": "full/Tween.min.js",
Expand All @@ -9,7 +9,6 @@
"directories": {
"example": "examples"
},
"types": "typings/Tween.d.ts",
"scripts": {
"source": "rollup -c",
"minify": "uglifyjs full/Tween.js -c -m -o full/Tween.min.js --source-map \"filename='full/Tween.min.js.map'\"",
Expand Down
10 changes: 6 additions & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ var plugins = [
]

export default {
entry: 'src/index.js',
input: 'src/index.js',
output: {
format: 'umd',
dest: 'full/Tween.js',
file: 'full/Tween.js'
},
globals: {
'intertween': 'InterTween'
},
sourceMap: true,
sourcemap: true,
context: 'this',
moduleName: 'TWEEN',
name: 'TWEEN',
plugins: plugins
}
12 changes: 7 additions & 5 deletions rollup.config.lite.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
export default {
entry: 'src/index.lite.js',
dest: 'lite/Tween.js',
format: 'umd',
sourceMap: true,
input: 'src/index.lite.js',
output: {
file: 'lite/Tween.js',
format: 'umd'
},
sourcemap: true,
context: 'this',
moduleName: 'TWEEN'
name: 'TWEEN'
}
5 changes: 1 addition & 4 deletions ts/Timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ class Timeline extends Tween {
const {
_tweens,
_duration,
_repeatDelayTime,
_reverseDelayTime,
_startTime,
_reversed,
Expand Down Expand Up @@ -290,9 +289,7 @@ class Timeline extends Tween {
this.timingOrder(timing => timing.reverse());
}

if (!_reversed && _repeatDelayTime) {
this._startTime = time + _repeatDelayTime;
} else if (_reversed && _reverseDelayTime) {
if (_reversed && _reverseDelayTime) {
this._startTime = time + _reverseDelayTime;
} else {
this._startTime = time;
Expand Down
33 changes: 8 additions & 25 deletions ts/Tween.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class Tween extends EventClass {
public _startTime: number;
public _initTime: number;
public _delayTime: number;
public _repeatDelayTime: number;
public _reverseDelayTime: number;
public _repeat: number;
public _yoyo: boolean;
Expand Down Expand Up @@ -244,23 +243,20 @@ class Tween extends EventClass {
}

/**
* Seek tween value by `time`
* Seek tween value by `time`. Note: Not works as excepted. PR are welcome
* @param {Time} time Tween update time
* @param {boolean=} keepPlaying When this param is set to `false`, tween pausing after seek
* @example tween.seek(500)
* @memberof Tween
* @deprecated
*/
public seek(time: number, keepPlaying?: boolean) {
const { _duration, _repeat, _initTime } = this;
const { _duration, _repeat, _initTime, _startTime } = this;

let updateTime: number = _initTime + time;
let updateTime: number = _startTime + time;
this._isPlaying = true;

if (keepPlaying) {
add(this);
}

this.update(updateTime, false, true);
this.update(time, false);

this.emit(EVENT_SEEK, time, this.object);

Expand Down Expand Up @@ -439,19 +435,6 @@ class Tween extends EventClass {
return this;
}

/**
* Set delay of each repeat of tween
* @param {number} amount Sets tween repeat delay / repeat wait duration
* @example tween.repeatDelay(400)
* @memberof Tween
*/
public repeatDelay(amount: number) {
this._repeatDelayTime =
typeof amount === 'function' ? amount(this._repeatDelayTime) : amount;

return this;
}

/**
* Set delay of each repeat alternate of tween
* @param {number} amount Sets tween repeat alternate delay / repeat alternate wait duration
Expand Down Expand Up @@ -536,7 +519,7 @@ class Tween extends EventClass {
_easingFunction,
_easingReverse,
_repeat,
_repeatDelayTime,
_delayTime,
_reverseDelayTime,
_yoyo,
_reversed,
Expand Down Expand Up @@ -603,9 +586,9 @@ class Tween extends EventClass {
this.emit(_yoyo && !_reversed ? EVENT_REVERSE : EVENT_REPEAT, object);

if (_reversed && _reverseDelayTime) {
this._startTime += _duration - _reverseDelayTime;
this._startTime = time - _reverseDelayTime;
} else {
this._startTime += _duration;
this._startTime = time + _delayTime;
}

return true;
Expand Down
27 changes: 7 additions & 20 deletions ts/lite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class Lite {
public _interpolationFunction: Function;
public _startTime: number;
public _delayTime: number;
public _repeatDelayTime: number;
public _reverseDelayTime: number;
public _repeat: number;
public _yoyo: boolean;
Expand Down Expand Up @@ -196,7 +195,10 @@ class Lite {
* @memberof Lite
*/
public start(time?: number) {
this._startTime = time !== undefined ? time : now();
this._startTime =
time !== undefined
? typeof time === 'string' ? now() + parseFloat(time) : time
: now();
this._startTime += this._delayTime;

const {
Expand Down Expand Up @@ -334,19 +336,6 @@ class Lite {
return this;
}

/**
* Set delay of each repeat of tween
* @param {number} amount Sets tween repeat delay / repeat wait duration
* @example tween.repeatDelay(500)
* @memberof Lite
*/
public repeatDelay(amount: number) {
this._repeatDelayTime =
typeof amount === 'function' ? amount(this._repeatDelayTime) : amount;

return this;
}

/**
* Set delay of each repeat alternate of tween
* @param {number} amount Sets tween repeat alternate delay / repeat alternate wait duration
Expand Down Expand Up @@ -415,7 +404,7 @@ class Lite {
_onStartCallbackFired,
_easingFunction,
_repeat,
_repeatDelayTime,
_delayTime,
_reverseDelayTime,
_yoyo,
_reversed,
Expand Down Expand Up @@ -490,12 +479,10 @@ class Lite {
this._reversed = !_reversed;
}

if (!_reversed && _repeatDelayTime) {
this._startTime = time + _repeatDelayTime;
} else if (_reversed && _reverseDelayTime) {
if (_reversed && _reverseDelayTime) {
this._startTime = time + _reverseDelayTime;
} else {
this._startTime = time;
this._startTime = time + _delayTime;
}

return true;
Expand Down

0 comments on commit 15b6cde

Please sign in to comment.