From 65ea13c700e5630ddf169cd2e23bc9bb01733a55 Mon Sep 17 00:00:00 2001 From: Davlat Shavkatov Date: Thu, 16 May 2019 22:53:32 +0500 Subject: [PATCH] fix interpolation bug and deprecate `.duration` method --- API.md | 8 +- package-lock.json | 306 +++++++++++++++++++++---------------------- package.json | 32 ++--- src/Interpolation.js | 27 ++-- src/Interpolator.js | 12 +- src/Tween.js | 13 +- src/constants.js | 30 ++--- test.js | 29 +++- 8 files changed, 237 insertions(+), 220 deletions(-) diff --git a/API.md b/API.md index 8fbd6f3..7c680ff 100644 --- a/API.md +++ b/API.md @@ -31,7 +31,7 @@ const {add, remove, isRunning, autoPlay} = TWEEN * [.Tween#play()](#TWEEN.Tween.Tween+play) * [.Tween#restart([noDelay])](#TWEEN.Tween.Tween+restart) * ~~[.Tween#seek(time, [keepPlaying])](#TWEEN.Tween.Tween+seek)~~ - * [.Tween#duration(amount)](#TWEEN.Tween.Tween+duration) + * ~~[.Tween#duration(amount)](#TWEEN.Tween.Tween+duration)~~ * [.Tween#to(properties, [duration])](#TWEEN.Tween.Tween+to) * [.Tween#start(time)](#TWEEN.Tween.Tween+start) * [.Tween#stop()](#TWEEN.Tween.Tween+stop) @@ -145,7 +145,7 @@ let tween = new Tween(myNode, {width:'100px'}).to({width:'300px'}, 2000).start() * [.Tween#play()](#TWEEN.Tween.Tween+play) * [.Tween#restart([noDelay])](#TWEEN.Tween.Tween+restart) * ~~[.Tween#seek(time, [keepPlaying])](#TWEEN.Tween.Tween+seek)~~ - * [.Tween#duration(amount)](#TWEEN.Tween.Tween+duration) + * ~~[.Tween#duration(amount)](#TWEEN.Tween.Tween+duration)~~ * [.Tween#to(properties, [duration])](#TWEEN.Tween.Tween+to) * [.Tween#start(time)](#TWEEN.Tween.Tween+start) * [.Tween#stop()](#TWEEN.Tween.Tween+stop) @@ -314,7 +314,9 @@ tween.seek(500) ``` -#### Tween.Tween#duration(amount) +#### ~~Tween.Tween#duration(amount)~~ +***Deprecated*** + Sets tween duration **Kind**: static method of [Tween](#TWEEN.Tween) diff --git a/package-lock.json b/package-lock.json index 8e4774f..22f23e8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "es6-tween", - "version": "5.5.2", + "version": "5.5.3", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -915,14 +915,6 @@ "dev": true, "requires": { "array-back": "^3.0.1" - }, - "dependencies": { - "array-back": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/array-back/-/array-back-3.1.0.tgz", - "integrity": "sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q==", - "dev": true - } } }, "ansi-escapes": { @@ -995,13 +987,10 @@ "dev": true }, "array-back": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/array-back/-/array-back-2.0.0.tgz", - "integrity": "sha512-eJv4pLLufP3g5kcZry0j6WXpIbzYw9GUB4mVJZno9wfwiBxbizTnHCw3VJb07cBihbFX48Y7oSrW9y+gt4glyw==", - "dev": true, - "requires": { - "typical": "^2.6.1" - } + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-3.1.0.tgz", + "integrity": "sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q==", + "dev": true }, "array-differ": { "version": "2.1.0", @@ -1213,12 +1202,6 @@ } } }, - "babylon": { - "version": "7.0.0-beta.19", - "resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.19.tgz", - "integrity": "sha512-Vg0C9s/REX6/WIXN37UKpv5ZhRi6A4pjHlpkE34+8/a6c2W1Q692n3hmc+SZG5lKRnaExLUbxtJ1SVT+KaCQ/A==", - "dev": true - }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -1389,6 +1372,17 @@ "array-back": "^2.0.0", "fs-then-native": "^2.0.0", "mkdirp2": "^1.0.3" + }, + "dependencies": { + "array-back": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-2.0.0.tgz", + "integrity": "sha512-eJv4pLLufP3g5kcZry0j6WXpIbzYw9GUB4mVJZno9wfwiBxbizTnHCw3VJb07cBihbFX48Y7oSrW9y+gt4glyw==", + "dev": true, + "requires": { + "typical": "^2.6.1" + } + } } }, "call-matcher": { @@ -1650,12 +1644,6 @@ "typical": "^4.0.0" }, "dependencies": { - "array-back": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/array-back/-/array-back-3.1.0.tgz", - "integrity": "sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q==", - "dev": true - }, "typical": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/typical/-/typical-4.0.0.tgz", @@ -1675,6 +1663,17 @@ "command-line-args": "^5.0.0", "command-line-usage": "^4.1.0", "typical": "^2.6.1" + }, + "dependencies": { + "array-back": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-2.0.0.tgz", + "integrity": "sha512-eJv4pLLufP3g5kcZry0j6WXpIbzYw9GUB4mVJZno9wfwiBxbizTnHCw3VJb07cBihbFX48Y7oSrW9y+gt4glyw==", + "dev": true, + "requires": { + "typical": "^2.6.1" + } + } } }, "command-line-usage": { @@ -1687,6 +1686,17 @@ "array-back": "^2.0.0", "table-layout": "^0.4.2", "typical": "^2.6.1" + }, + "dependencies": { + "array-back": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-2.0.0.tgz", + "integrity": "sha512-eJv4pLLufP3g5kcZry0j6WXpIbzYw9GUB4mVJZno9wfwiBxbizTnHCw3VJb07cBihbFX48Y7oSrW9y+gt4glyw==", + "dev": true, + "requires": { + "typical": "^2.6.1" + } + } } }, "commander": { @@ -2071,37 +2081,37 @@ } }, "dmd": { - "version": "3.0.13", - "resolved": "https://registry.npmjs.org/dmd/-/dmd-3.0.13.tgz", - "integrity": "sha512-FV/417bH2c/CYpe8BjFEAHoaHaItcJnPlKELi/qyPZdmUom8joyuC78OhhfPUdyKD/WcouTQ2LxQT4M/RoiJ3w==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/dmd/-/dmd-4.0.0.tgz", + "integrity": "sha512-J+4CgbQiMuJHiU9dvTVN8iOOZGeR3bef1wBqz6eVvvX17jkpkKVd8TeeutA/FJAeFbLQfXnyQ3o4qY7W+c5cxQ==", "dev": true, "requires": { - "array-back": "^2.0.0", + "array-back": "^3.1.0", "cache-point": "^0.4.1", "common-sequence": "^1.0.2", "file-set": "^2.0.0", - "handlebars": "^4.0.11", - "marked": "^0.3.16", + "handlebars": "^4.1.2", + "marked": "^0.6.2", "object-get": "^2.1.0", - "reduce-flatten": "^1.0.1", - "reduce-unique": "^1.0.0", + "reduce-flatten": "^2.0.0", + "reduce-unique": "^2.0.1", "reduce-without": "^1.0.1", "test-value": "^3.0.0", - "walk-back": "^3.0.0" + "walk-back": "^3.0.1" }, "dependencies": { - "marked": { - "version": "0.3.19", - "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.19.tgz", - "integrity": "sha512-ea2eGWOqNxPcXv8dyERdSr/6FmzvWwzjMxpfGB/sbMccXoct+xY+YukPD+QTUZwyvK7BZwcr4m21WBOW41pAkg==", + "reduce-flatten": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/reduce-flatten/-/reduce-flatten-2.0.0.tgz", + "integrity": "sha512-EJ4UNY/U1t2P/2k6oqotuX2Cc3T6nxJwsM0N0asT7dhrtH1ltUxDn4NalSYmPE2rCkVpcf/X6R0wDwcFpzhd4w==", "dev": true } } }, "docdash": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/docdash/-/docdash-0.4.0.tgz", - "integrity": "sha1-BcOlDYMYmYFpnuDAdtOjlQ237AA=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/docdash/-/docdash-1.1.0.tgz", + "integrity": "sha512-sgcessH25PU6CIoJGeOjDCv9CLi6Z6TLwc553s/O+DKCnIRXT58e4CG3WsgI8Zea5ZQcjsfa8u4IwKqR2TKTxQ==", "dev": true }, "doctrine": { @@ -2580,17 +2590,17 @@ } }, "eslint-plugin-node": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-8.0.1.tgz", - "integrity": "sha512-ZjOjbjEi6jd82rIpFSgagv4CHWzG9xsQAVp1ZPlhRnnYxcTgENUVBvhYmkQ7GvT1QFijUSo69RaiOJKhMu6i8w==", + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-9.0.1.tgz", + "integrity": "sha512-fljT5Uyy3lkJzuqhxrYanLSsvaILs9I7CmQ31atTtZ0DoIzRbbvInBh4cQ1CrthFHInHYBQxfPmPt6KLHXNXdw==", "dev": true, "requires": { - "eslint-plugin-es": "^1.3.1", + "eslint-plugin-es": "^1.4.0", "eslint-utils": "^1.3.1", - "ignore": "^5.0.2", + "ignore": "^5.1.1", "minimatch": "^3.0.4", - "resolve": "^1.8.1", - "semver": "^5.5.0" + "resolve": "^1.10.1", + "semver": "^6.0.0" }, "dependencies": { "ignore": { @@ -2598,6 +2608,12 @@ "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.1.tgz", "integrity": "sha512-DWjnQIFLenVrwyRCKZT+7a7/U4Cqgar4WG8V++K3hw+lrW1hc/SIwdiGmtxKCVACmHULTuGeBbHJmbwW7/sAvA==", "dev": true + }, + "semver": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.0.0.tgz", + "integrity": "sha512-0UewU+9rFapKFnlbirLi3byoOuhrSsli/z/ihNnvM24vgF+8sNBiI1LZPBSH9wJKUwaUbw+s3hToDLCXkrghrQ==", + "dev": true } } }, @@ -2973,6 +2989,17 @@ "requires": { "array-back": "^2.0.0", "glob": "^7.1.3" + }, + "dependencies": { + "array-back": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-2.0.0.tgz", + "integrity": "sha512-eJv4pLLufP3g5kcZry0j6WXpIbzYw9GUB4mVJZno9wfwiBxbizTnHCw3VJb07cBihbFX48Y7oSrW9y+gt4glyw==", + "dev": true, + "requires": { + "typical": "^2.6.1" + } + } } }, "fill-range": { @@ -3005,14 +3032,6 @@ "dev": true, "requires": { "array-back": "^3.0.1" - }, - "dependencies": { - "array-back": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/array-back/-/array-back-3.1.0.tgz", - "integrity": "sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q==", - "dev": true - } } }, "find-up": { @@ -4334,9 +4353,9 @@ } }, "jsdoc": { - "version": "3.6.1", - "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.6.1.tgz", - "integrity": "sha512-mMMsst31b8c7/Z6ewnO6ORIdVMwsobg1enX9b/2XAzW8mM3KuMANRWcMD1KMBq91IAUMOIhC5NsXu7xvNQrRyQ==", + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.6.2.tgz", + "integrity": "sha512-S2vzg99C5+gb7FWlrK4TVdyzVPGGkdvpDkCEJH1JABi2PKzPeLu5/zZffcJUifgWUJqXWl41Hoc+MmuM2GukIg==", "dev": true, "requires": { "@babel/parser": "^7.4.4", @@ -4370,78 +4389,20 @@ } }, "jsdoc-api": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/jsdoc-api/-/jsdoc-api-4.0.3.tgz", - "integrity": "sha512-dfYq9JgB+XahY0XfSEw93PmXmocjwYcvJ5aMuQUJ/OdDRGWamf2SSOk3W06Bsj8qdjp/UdefzqpP/mpwsvHuvA==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/jsdoc-api/-/jsdoc-api-5.0.1.tgz", + "integrity": "sha512-bntcT/3No4dPJZs9KX0AN3vrX/7P6PwDXVKANCXYpa0WJsbud41yAunoMxGFS4APHwmDoWl8E0ZuowLCOiOOFw==", "dev": true, "requires": { - "array-back": "^2.0.0", + "array-back": "^3.1.0", "cache-point": "^0.4.1", "collect-all": "^1.0.3", - "file-set": "^2.0.0", + "file-set": "^2.0.1", "fs-then-native": "^2.0.0", - "jsdoc": "~3.5.5", + "jsdoc": "^3.6.1", "object-to-spawn-args": "^1.1.1", "temp-path": "^1.0.0", - "walk-back": "^3.0.0" - }, - "dependencies": { - "js2xmlparser": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-3.0.0.tgz", - "integrity": "sha1-P7YOqgicVED5MZ9RdgzNB+JJlzM=", - "dev": true, - "requires": { - "xmlcreate": "^1.0.1" - } - }, - "jsdoc": { - "version": "3.5.5", - "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.5.5.tgz", - "integrity": "sha512-6PxB65TAU4WO0Wzyr/4/YhlGovXl0EVYfpKbpSroSj0qBxT4/xod/l40Opkm38dRHRdQgdeY836M0uVnJQG7kg==", - "dev": true, - "requires": { - "babylon": "7.0.0-beta.19", - "bluebird": "~3.5.0", - "catharsis": "~0.8.9", - "escape-string-regexp": "~1.0.5", - "js2xmlparser": "~3.0.0", - "klaw": "~2.0.0", - "marked": "~0.3.6", - "mkdirp": "~0.5.1", - "requizzle": "~0.2.1", - "strip-json-comments": "~2.0.1", - "taffydb": "2.6.2", - "underscore": "~1.8.3" - } - }, - "klaw": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/klaw/-/klaw-2.0.0.tgz", - "integrity": "sha1-WcEo4Nxc5BAgEVEZTuucv4WGUPY=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.9" - } - }, - "marked": { - "version": "0.3.19", - "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.19.tgz", - "integrity": "sha512-ea2eGWOqNxPcXv8dyERdSr/6FmzvWwzjMxpfGB/sbMccXoct+xY+YukPD+QTUZwyvK7BZwcr4m21WBOW41pAkg==", - "dev": true - }, - "underscore": { - "version": "1.8.3", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", - "integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=", - "dev": true - }, - "xmlcreate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-1.0.2.tgz", - "integrity": "sha1-+mv3YqYKQT+z3Y9LA8WyaSONMI8=", - "dev": true - } + "walk-back": "^3.0.1" } }, "jsdoc-parse": { @@ -4456,21 +4417,32 @@ "reduce-extract": "^1.0.0", "sort-array": "^2.0.0", "test-value": "^3.0.0" + }, + "dependencies": { + "array-back": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-2.0.0.tgz", + "integrity": "sha512-eJv4pLLufP3g5kcZry0j6WXpIbzYw9GUB4mVJZno9wfwiBxbizTnHCw3VJb07cBihbFX48Y7oSrW9y+gt4glyw==", + "dev": true, + "requires": { + "typical": "^2.6.1" + } + } } }, "jsdoc-to-markdown": { - "version": "3.1.0-1", - "resolved": "https://registry.npmjs.org/jsdoc-to-markdown/-/jsdoc-to-markdown-3.1.0-1.tgz", - "integrity": "sha512-n7xTOJT89JbCs3biMrNBvYiAIgxLQszs/1kKDEcJ1nh9hSvUbBh+w+TTcMF6bgqF76fowVJWpCh90zdZYOTT8w==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/jsdoc-to-markdown/-/jsdoc-to-markdown-5.0.0.tgz", + "integrity": "sha512-3gKEnbay7dSdyvtMDDkUf4r7pmBVgs3aqeT0Cg/ngTILPpJUzf8iKgASIo5psF007L45OIJtIuRX5VL/YUXKaA==", "dev": true, "requires": { - "array-back": "^2.0.0", + "array-back": "^3.1.0", "command-line-tool": "^0.8.0", "config-master": "^3.1.0", - "dmd": "^3.0.9", - "jsdoc-api": "^4.0.1", + "dmd": "^4.0.0", + "jsdoc-api": "^5.0.1", "jsdoc-parse": "^3.0.1", - "walk-back": "^3.0.0" + "walk-back": "^3.0.1" } }, "jsesc": { @@ -4832,9 +4804,9 @@ } }, "mime": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.2.tgz", - "integrity": "sha512-zJBfZDkwRu+j3Pdd2aHsR5GfH2jIWhmL1ZzBoc+X+3JEti2hbArWcyJ+1laC1D2/U/W1a/+Cegj0/OnEU2ybjg==", + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.3.tgz", + "integrity": "sha512-QgrPRJfE+riq5TPZMcHZOtm8c6K/yYrMbKIoRfapfiGLxS8OTeIfRhUGW5LU7MlRa52KOAGCfUNruqLrIBvWZw==", "dev": true }, "mimic-fn": { @@ -4969,9 +4941,9 @@ "dev": true }, "neo-async": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.0.tgz", - "integrity": "sha512-MFh0d/Wa7vkKO3Y3LlacqAEeHK0mckVqzDieUKTT+KGxi+zIpeVsFxymkIiRpbpDziHc290Xr9A1O4Om7otoRA==", + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz", + "integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==", "dev": true }, "nice-try": { @@ -5472,9 +5444,9 @@ "dev": true }, "puppeteer": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.15.0.tgz", - "integrity": "sha512-D2y5kwA9SsYkNUmcBzu9WZ4V1SGHiQTmgvDZSx6sRYFsgV25IebL4V6FaHjF6MbwLK9C6f3G3pmck9qmwM8H3w==", + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.16.0.tgz", + "integrity": "sha512-7hcmbUw+6INffSPBdnO8KSjJRg2bLRoI7EeZMf5MHdV5kpyYMeoMR5w8AIiZbKIhYGwrXlbgvO7gFTsXNHShuQ==", "dev": true, "requires": { "debug": "^4.1.0", @@ -5644,9 +5616,9 @@ "dev": true }, "reduce-unique": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/reduce-unique/-/reduce-unique-1.0.0.tgz", - "integrity": "sha1-flhrz4ek4ytter2Cd/rWzeyfSAM=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/reduce-unique/-/reduce-unique-2.0.1.tgz", + "integrity": "sha512-x4jH/8L1eyZGR785WY+ePtyMNhycl1N2XOLxhCbzZFaqF4AXjLzqSxa2UHgJ2ZVR/HHyPOvl1L7xRnW8ye5MdA==", "dev": true }, "reduce-without": { @@ -5879,20 +5851,20 @@ } }, "rollup": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.11.3.tgz", - "integrity": "sha512-81MR7alHcFKxgWzGfG7jSdv+JQxSOIOD/Fa3iNUmpzbd7p+V19e1l9uffqT8/7YAHgGOzmoPGN3Fx3L2ptOf5g==", + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.12.1.tgz", + "integrity": "sha512-6CL0c+HxqEY9/8G+7mYIvor0tt60mVC64410/1DeaGWZCFAvcY8ClT0bsnTxECd6vR004CMm0X2yBZmod5gWjw==", "dev": true, "requires": { "@types/estree": "0.0.39", - "@types/node": "^11.13.9", + "@types/node": "^12.0.2", "acorn": "^6.1.1" }, "dependencies": { "@types/node": { - "version": "11.13.10", - "resolved": "https://registry.npmjs.org/@types/node/-/node-11.13.10.tgz", - "integrity": "sha512-leUNzbFTMX94TWaIKz8N15Chu55F9QSH+INKayQr5xpkasBQBRF3qQXfo3/dOnMU/dEIit+Y/SU8HyOjq++GwA==", + "version": "12.0.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.2.tgz", + "integrity": "sha512-5tabW/i+9mhrfEOUcLDu2xBPsHJ+X5Orqy9FKpale3SjDA17j5AEpYq5vfy3oAeAHGcvANRCO3NV3d2D6q3NiA==", "dev": true } } @@ -6495,6 +6467,17 @@ "lodash.padend": "^4.6.1", "typical": "^2.6.1", "wordwrapjs": "^3.0.0" + }, + "dependencies": { + "array-back": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-2.0.0.tgz", + "integrity": "sha512-eJv4pLLufP3g5kcZry0j6WXpIbzYw9GUB4mVJZno9wfwiBxbizTnHCw3VJb07cBihbFX48Y7oSrW9y+gt4glyw==", + "dev": true, + "requires": { + "typical": "^2.6.1" + } + } } }, "taffydb": { @@ -6526,6 +6509,17 @@ "requires": { "array-back": "^2.0.0", "typical": "^2.6.1" + }, + "dependencies": { + "array-back": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-2.0.0.tgz", + "integrity": "sha512-eJv4pLLufP3g5kcZry0j6WXpIbzYw9GUB4mVJZno9wfwiBxbizTnHCw3VJb07cBihbFX48Y7oSrW9y+gt4glyw==", + "dev": true, + "requires": { + "typical": "^2.6.1" + } + } } }, "text-table": { @@ -6667,9 +6661,9 @@ "dev": true }, "uglify-js": { - "version": "3.5.11", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.5.11.tgz", - "integrity": "sha512-izPJg8RsSyqxbdnqX36ExpbH3K7tDBsAU/VfNv89VkMFy3z39zFjunQGsSHOlGlyIfGLGprGeosgQno3bo2/Kg==", + "version": "3.5.12", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.5.12.tgz", + "integrity": "sha512-KeQesOpPiZNgVwJj8Ge3P4JYbQHUdZzpx6Fahy6eKAYRSV4zhVmLXoC+JtOeYxcHCHTve8RG1ZGdTvpeOUM26Q==", "dev": true, "requires": { "commander": "~2.20.0", diff --git a/package.json b/package.json index 86e4174..75a4ef2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "es6-tween", - "version": "5.5.3", + "version": "5.5.4", "description": "ES6 implementation of amazing tween.js", "browser": "bundled/Tween.min.js", "cdn": "bundled/Tween.min.js", @@ -15,7 +15,7 @@ "build": "npm run source && npm run minify", "dev": "npx rollup -c -w", "prepublishOnly": "npm run build && npm run lint && npm run doc && npm run doc-md", - "doc": "npx jsdoc --readme README.md --configure jsdoc.json --verbose --debug", + "doc": "npx jsdoc --readme README.md --configure jsdoc.json", "doc-md": "npx jsdoc2md src/** > API.md", "test": "npm run lint && npm run source && npx ava", "lint": "npx eslint ./src", @@ -41,23 +41,23 @@ }, "homepage": "https://es6-tween.js.org", "devDependencies": { - "@babel/core": "^7.3.3", - "@babel/plugin-proposal-class-properties": "^7.3.3", - "@babel/preset-env": "^7.3.1", - "ava": "^1.2.1", - "docdash": "^0.4.0", - "eslint": "^5.14.1", + "@babel/core": "^7.4.4", + "@babel/plugin-proposal-class-properties": "^7.4.4", + "@babel/preset-env": "^7.4.4", + "ava": "^1.4.1", + "docdash": "^1.1.0", + "eslint": "^5.16.0", "eslint-config-standard": "^12.0.0", - "eslint-plugin-import": "^2.16.0", - "eslint-plugin-node": "^8.0.1", - "eslint-plugin-promise": "^4.0.1", + "eslint-plugin-import": "^2.17.2", + "eslint-plugin-node": "^9.0.1", + "eslint-plugin-promise": "^4.1.1", "eslint-plugin-standard": "^4.0.0", - "jsdoc": "^3.5.5", - "jsdoc-to-markdown": "^3.1.0-1", - "puppeteer": "^1.12.2", - "rollup": "^1.2.3", + "jsdoc": "^3.6.2", + "jsdoc-to-markdown": "^5.0.0", + "puppeteer": "^1.16.0", + "rollup": "^1.12.1", "rollup-plugin-babel": "^4.3.2", - "uglify-js": "^3.4.9" + "uglify-js": "^3.5.12" }, "dependencies": {}, "ava": { diff --git a/src/Interpolation.js b/src/Interpolation.js index 024b7e9..236f5e7 100644 --- a/src/Interpolation.js +++ b/src/Interpolation.js @@ -16,6 +16,7 @@ const Interpolation = { const f = m * k const i = Math.floor(f) const fn = Interpolation.Utils.Linear + if (k < 0) { return fn(v[0], v[1], f, value) } @@ -93,25 +94,35 @@ const Interpolation = { Utils: { Linear (p0, p1, t, v) { - if (typeof p0 === 'string') { + if (p0 === p1 || typeof p0 === 'string') { + // Quick return for performance reason + if (p1.length && p1.splice && p1.isString) { + p1 = '' + for (let i = 0, len = p0.length; i < len; i++) { + p1 += p0[i] + } + } return p1 } else if (typeof p0 === 'number') { return typeof p0 === 'function' ? p0(t) : p0 + (p1 - p0) * t } else if (typeof p0 === 'object') { if (p0.length !== undefined) { - if (p0[0] === STRING_PROP) { + const isForceStringProp = typeof p0[0] === 'string' || p0.isString + if (isForceStringProp || p0[0] === STRING_PROP) { let STRING_BUFFER = '' - for (let i = 1, len = p0.length; i < len; i++) { - let currentValue = typeof p0[i] === 'number' ? p0[i] + (p1[i] - p0[i]) * t : p1[i] - if (isRGBColor(p0, i) || isRGBColor(p0, i, RGBA)) { + for (let i = isForceStringProp ? 0 : 1, len = p0.length; i < len; i++) { + let currentValue = + t === 0 ? p0[i] : t === 1 ? p1[i] : typeof p0[i] === 'number' ? p0[i] + (p1[i] - p0[i]) * t : p1[i] + if ((t > 0 && t < 1 && isRGBColor(p0, i)) || isRGBColor(p0, i, RGBA)) { currentValue |= 0 } STRING_BUFFER += currentValue } return STRING_BUFFER - } - for (let p = 0, len = v.length; p < len; p++) { - v[p] = Interpolation.Utils.Linear(p0[p], p1[p], t, v[p]) + } else if (v && v.length && v.splice) { + for (let p = 0, len = v.length; p < len; p++) { + v[p] = Interpolation.Utils.Linear(p0[p], p1[p], t, v[p]) + } } } else { for (const p in v) { diff --git a/src/Interpolator.js b/src/Interpolator.js index 1d0bcfb..b07d0df 100644 --- a/src/Interpolator.js +++ b/src/Interpolator.js @@ -9,7 +9,7 @@ import { decompose, recompose, decomposeString } from './constants' * @return {Function} Returns function that accepts number between `0-1` */ const Interpolator = (a, b) => { - let isArray = Array.isArray(a) + let isArray = Array.isArray(a) && !a.isString let origin = typeof a === 'string' ? a : isArray ? a.slice() : { ...a } if (isArray) { for (let i = 0, len = a.length; i < len; i++) { @@ -33,14 +33,8 @@ const Interpolator = (a, b) => { } } - let c = { isString: true, length: a.length } - let d = { isString: true, length: b.length } - - while (i < c.length) { - c[i] = a[i] - d[i] = b[i] - i++ - } + a.isString = true + b.isString = true } return function (t) { if (isArray) { diff --git a/src/Tween.js b/src/Tween.js index 7915420..e674f4a 100644 --- a/src/Tween.js +++ b/src/Tween.js @@ -334,6 +334,7 @@ class Tween { * @param {number} amount Duration is milliseconds * @example tween.duration(2000) * @memberof TWEEN.Tween + * @deprecated Not works as excepted and useless, so we deprecated this method */ duration (amount) { this._duration = typeof amount === 'function' ? amount(this._duration) : amount @@ -430,14 +431,8 @@ class Tween { for (let i = 0, len = end.length; i < len; i++) { if (typeof end[i] === 'string') { let arrayOfStrings = decomposeString(end[i]) - let stringObject = { - length: arrayOfStrings.length, - isString: true - } - for (let ii = 0, len2 = arrayOfStrings.length; ii < len2; ii++) { - stringObject[ii] = arrayOfStrings[ii] - } - end[i] = stringObject + arrayOfStrings.isString = true + end[i] = arrayOfStrings } } } @@ -717,7 +712,7 @@ class Tween { if (typeof end === 'number') { object[property] = start + (end - start) * value - } else if (Array.isArray(end) && !Array.isArray(start)) { + } else if (Array.isArray(end) && !end.isString && (!Array.isArray(start) || start.isString)) { object[property] = _interpolationFunctionCall(end, value, object[property]) } else if (end && end.update) { end.update(value) diff --git a/src/constants.js b/src/constants.js index b34f2f3..d6c8ea9 100644 --- a/src/constants.js +++ b/src/constants.js @@ -73,7 +73,15 @@ export function decompose (prop, obj, from, to, stringBuffer) { const fromValue = from[prop] const toValue = to[prop] - if (typeof fromValue === 'string' || typeof toValue === 'string') { + if (typeof fromValue === 'string' && Array.isArray(toValue)) { + const fromValue1 = decomposeString(fromValue) + const toValues = toValue.map(decomposeString) + + fromValue1.isString = true + from[prop] = fromValue1 + to[prop] = toValues + return true + } else if (typeof fromValue === 'string' || typeof toValue === 'string') { let fromValue1 = Array.isArray(fromValue) && fromValue[0] === STRING_PROP ? fromValue : decomposeString(fromValue) let toValue1 = Array.isArray(toValue) && toValue[0] === STRING_PROP ? toValue : decomposeString(toValue) @@ -96,23 +104,11 @@ export function decompose (prop, obj, from, to, stringBuffer) { toValue1.shift() } - let fromValue2 = { - isString: true, - length: fromValue1.length - } - let toValue2 = { - isString: true, - length: toValue1.length - } - - while (i < fromValue2.length) { - fromValue2[i] = fromValue1[i] - toValue2[i] = toValue1[i] - i++ - } + fromValue1.isString = true + toValue1.isString = true - from[prop] = fromValue2 - to[prop] = toValue2 + from[prop] = fromValue1 + to[prop] = toValue1 return true } else if (typeof fromValue === 'object' && typeof toValue === 'object') { if (Array.isArray(fromValue)) { diff --git a/test.js b/test.js index 715e0ee..1afdaca 100644 --- a/test.js +++ b/test.js @@ -48,7 +48,7 @@ test('Events', (t) => { }) test('Value Interpolation', (t) => { - let obj = { a: 0, b: 'B value 1', c: { x: 2 }, d: [3], _e: 4, g: 5, h: 0 } + let obj = { a: 0, b: 'B value 1', c: { x: 2 }, d: [3], _e: 4, g: 5, h: 0, j: 0, k: 'rgb(0, 0, 0)' } Object.defineProperty(obj, 'e', { get () { @@ -59,7 +59,22 @@ test('Value Interpolation', (t) => { } }) - new Tween(obj).to({ a: 1, b: 'B value 2', c: { x: 3 }, d: [4], _e: 5, g: '+=1', h: 250000 }, 100).start(0) + new Tween(obj) + .to( + { + a: 1, + b: 'B value 2', + c: { x: 3 }, + d: [4], + _e: 5, + g: '+=1', + h: 250000, + j: [1, 2], + k: ['rgb(100, 100, 100)', 'rgb(200, 200, 200)'] + }, + 100 + ) + .start(0) update(0) @@ -70,6 +85,8 @@ test('Value Interpolation', (t) => { t.is(obj.e, 4) t.is(obj.g, 5) t.is(obj.h, 0) + t.is(obj.j, 0) + t.is(obj.k, 'rgb(0, 0, 0)') update(50) @@ -94,6 +111,12 @@ test('Value Interpolation', (t) => { t.is(obj.h, 125000, 'Big number interpolation not worked as excepted') t.log('Big number interpolation worked as excepted') + t.is(obj.j, 1, 'Multi-Interpolation not worked as excepted') + t.log('Multi-Interpolation worked as excepted') + + t.is(obj.k, 'rgb(100, 100, 100)', 'Multi-Interpolation not worked as excepted') + t.log('Multi-Interpolation worked as excepted') + update(100) t.is(obj.a, 1) @@ -103,6 +126,8 @@ test('Value Interpolation', (t) => { t.is(obj.e, 5) t.is(obj.g, 6) t.is(obj.h, 250000, 'Big number interpolation ending value not worked as excepted') + t.is(obj.j, 2, 'Multi-Interpolation not worked as excepted') + t.is(obj.k, 'rgb(200, 200, 200)', 'Multi-Interpolation not worked as excepted') }) test('Value Array-based Interpolation', (t) => {