Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

es6-tween

Package Overview
Dependencies
Maintainers
1
Versions
127
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es6-tween - npm Package Compare versions

Comparing version 5.3.2 to 5.4.0

.babelrc

21

package.json
{
"name": "es6-tween",
"version": "5.3.2",
"version": "5.4.0",
"description": "ES6 implementation of amazing tween.js",

@@ -17,6 +17,6 @@ "browser": "bundled/Tween.min.js",

"dev": "npx rollup -c -w",
"prepublishOnly": "yarn build && npx ava --verbose && yarn doc && yarn doc-md",
"prepublishOnly": "yarn lint && yarn doc && yarn doc-md",
"doc": "npx jsdoc --readme README.md --configure jsdoc.json --verbose",
"doc-md": "npx jsdoc2md src/** > API.md",
"test": "yarn lint && yarn source && npx ava --verbose",
"test": "yarn lint && npm run source && npx ava",
"lint": "npx eslint ./src",

@@ -59,2 +59,3 @@ "lint-fix": "npx eslint ./src --fix"

"jsdoc-to-markdown": "^3.1.0-1",
"puppeteer": "^1.12.2",
"rollup": "^1.2.3",

@@ -64,3 +65,15 @@ "rollup-plugin-babel": "^4.3.2",

},
"dependencies": {}
"dependencies": {},
"ava": {
"verbose": true,
"require": [
"esm"
],
"babel": {
"extensions": [
"js",
"mjs"
]
}
}
}

70

README.md

@@ -8,11 +8,9 @@ # es6-tween

[![size](http://img.badgesize.io/https://unpkg.com/es6-tween?cache=false)](https://unpkg.com/es6-tween)
[![gzipsize](http://img.badgesize.io/https://unpkg.com/es6-tween?compression=gzip&cache=false)](https://unpkg.com/es6-tween)
[![CDNJS](https://img.shields.io/cdnjs/v/es6-tween.svg)](https://cdnjs.com/libraries/es6-tween)
[![jsdelivr](https://img.shields.io/badge/cdn-jsdelivr-brightgreen.svg)](https://cdn.jsdelivr.net/npm/es6-tween) [![unpkg](https://img.shields.io/badge/cdn-unpkg-brightgreen.svg)](https://unpkg.com/es6-tween) [![npmcdn](https://img.shields.io/badge/cdn-npmcdn-brightgreen.svg)](https://npmcdn.com/es6-tween)
[![NPM Min Size][npm-min-size]][unpkg-url]
[![NPM Gzip Size][npm-gzip-size]][unpkg-url]
[![CDNJS][cdnjs-image]][cdnjs-url]
[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![NPM Downloads][downloads-image]][npm-url]
[![license](https://img.shields.io/github/license/tweenjs/es6-tween.svg)]()
[![Travis tests][travis-image]][travis-url]
[![Flattr this][flattr-image]][flattr-url]
<br/>

@@ -26,3 +24,10 @@ [![NPM](https://nodei.co/npm/es6-tween.png?downloads=true&stars=true)](https://nodei.co/npm/es6-tween/)

# Docs
* [See docs at GitBook](https://tweenjs.gitbook.io/es6-tween/)
* [Homepage](https://tweenjs.github.io/es6-tween/) (not completed)
* [API documentation](./API.md)
* [Wiki page](https://github.com/tweenjs/es6-tween/wiki)
```javascript

@@ -149,45 +154,2 @@ TWEEN.autoPlay(true); // simplify the your code

## Compatiblity
All ES5 supported browsers including IE9+
#### Browsers
* Chrome
* Firefox 3.5+
* Opera 9.5+
* IE8+
* Safari 5.1+
#### OS (Fully working)
* Android 4.1+
* iOS6+
* WP8.5+
* OS X
* Windows 7+
#### Device
* iPhone
* iPad
* Android devices
* Nokia Lumia
* Samsung devices
* - all devices should compatible with supported OS
#### Package managers
* `npm`
* `yarn`
#### Bundler
* `Rollup`
#### Transpiler
* `Babel`
## Documentation
* Original source: <a href="https://github.com/tweenjs/tween.js">check out at here</a>
* [Full documentation](https://tweenjs.github.io/es6-tween/)
* [API documentation](./API.md)
* [Wiki page](https://github.com/tweenjs/es6-tween/wiki)
* [Tutorial](https://learningthreejs.com/blog/2011/08/17/tweenjs-for-smooth-animation/) using tween.js with three.js
## Compatiblity Testing

@@ -200,6 +162,2 @@

## Examples
Demos with this version are not yet implemented, sorry.
## Tests

@@ -241,11 +199,11 @@

[npm-min-size]: https://img.shields.io/bundlephobia/min/es6-tween.svg
[npm-gzip-size]: https://img.badgesize.io/https://unpkg.com/es6-tween?compression=gzip
[npm-image]: https://img.shields.io/npm/v/es6-tween.svg
[npm-url]: https://npmjs.org/package/es6-tween
[downloads-image]: https://img.shields.io/npm/dm/es6-tween.svg
[downloads-url]: https://npmjs.org/package/es6-tween
[travis-image]: https://travis-ci.org/tweenjs/es6-tween.svg?branch=master
[travis-url]: https://travis-ci.org/tweenjs/es6-tween
[flattr-image]: https://api.flattr.com/button/flattr-badge-large.png
[flattr-url]: https://flattr.com/submit/auto?fid=kxw7jx&url=https%3A%2F%2Fgithub.com%2Ftweenjs%2Fes6-tween
[cdnjs-image]: https://img.shields.io/cdnjs/v/es6-tween.svg
[cdnjs-url]: https://cdnjs.com/libraries/es6-tween
[unpkg-url]: https://unpkg.com/es6-tween

@@ -13,19 +13,4 @@ import babel from 'rollup-plugin-babel'

plugins: [
babel({
babelrc: false,
exclude: ['node_modules/**', 'bundles/**', 'performance/**', 'logo/**', 'examples/**'],
presets: [
[
'@babel/preset-env',
{
modules: false,
shippedProposals: true
}
]
],
plugins: [
'@babel/plugin-proposal-class-properties'
]
})
babel()
]
}
/* global process */
import { requestAnimationFrame, root } from './shim'
import { requestAnimationFrame, cancelAnimationFrame, root } from './shim'

@@ -43,3 +43,3 @@ /**

* Lightweight, effecient and modular ES6 version of tween.js
* @copyright 2017 @dalisoft and es6-tween contributors
* @copyright 2019 @dalisoft and es6-tween contributors
* @license MIT

@@ -58,2 +58,3 @@ * @namespace TWEEN

let powerModeThrottle = 120
let _tick

@@ -91,6 +92,4 @@ const onRequestTick = (fn) => {

if (_autoPlay && !isStarted) {
_ticker(update)
_tick = _ticker(update)
isStarted = true
} else {
_requestTick()
}

@@ -116,3 +115,3 @@ }

const FrameThrottle = (frameCount = 120) => {
powerModeThrottle = frameCount
powerModeThrottle = frameCount * 1.05
}

@@ -144,2 +143,3 @@

_tweens.length = 0
cancelAnimationFrame(_tick)
}

@@ -186,2 +186,5 @@

}
if (_tweens.length === 0) {
cancelAnimationFrame(_tick)
}
}

@@ -202,2 +205,3 @@

emptyFrame = 0
cancelAnimationFrame(_tick)
return false

@@ -207,3 +211,3 @@ }

if (_autoPlay && isStarted) {
_ticker(update)
_tick = _ticker(update)
} else {

@@ -210,0 +214,0 @@ _requestTick()

@@ -20,4 +20,6 @@ import {

import Tween from './Tween'
import Timeline from './Timeline'
import Selector from './selector'
import Interpolator from './Interpolator'
import * as utils from './constants'
import './shim'

@@ -42,4 +44,6 @@ export {

Tween,
Timeline,
Easing,
Interpolation
Interpolation,
utils
}

@@ -1,6 +0,6 @@

export default function (selector, collection) {
export default function (selector, collection, allowRaw) {
if (collection) {
return !selector
? null
: selector === window || selector === document
: (typeof window !== 'undefined' && selector === window) || (typeof document !== 'undefined' && selector === document)
? [selector]

@@ -11,7 +11,7 @@ : typeof selector === 'string'

? selector
: selector.nodeType ? [selector] : []
: selector.nodeType ? [selector] : allowRaw ? selector : []
}
return !selector
? null
: selector === window || selector === document
: (typeof window !== 'undefined' && selector === window) || (typeof document !== 'undefined' && selector === document)
? selector

@@ -22,3 +22,3 @@ : typeof selector === 'string'

? selector[0]
: selector.nodeType ? selector : null
: selector.nodeType ? selector : allowRaw ? selector : null
}

@@ -1,22 +0,14 @@

/* global global */
export let assign = (source, ...args) => {
for (let i = 0, len = args.length; i < len; i++) {
const arg = args[i]
for (const p in arg) {
source[p] = arg[p]
}
}
return source
}
export let create =
Object.create || ((source = {}) => ({ ...source }))
/* global global, self */
export let root =
typeof window !== 'undefined'
? window
: typeof global !== 'undefined' ? global : this
typeof self !== 'undefined'
? self : typeof window !== 'undefined'
? window
: typeof global !== 'undefined'
? global : this || (typeof exports !== 'undefined'
? exports : {})
export let requestAnimationFrame =
root.requestAnimationFrame ||
((fn) => root.setTimeout(fn, 16))
((fn) => root.setTimeout(fn, 50 / 3))
export let cancelAnimationFrame =
root.cancelAnimationFrame ||
((id) => root.clearTimeout(id))

@@ -5,3 +5,4 @@ import {

Plugins,
remove
remove,
isRunning
} from './core'

@@ -105,3 +106,3 @@ import Easing from './Easing'

this._valuesEnd = null
this._valuesStart = {}
this._valuesStart = Array.isArray(object) ? [] : {}

@@ -738,3 +739,3 @@ this._duration = 1000

this._prevTime = time
if (delta > TOO_LONG_FRAME_MS) {
if (delta > TOO_LONG_FRAME_MS && isRunning()) {
time -= delta - FRAME_MS

@@ -741,0 +742,0 @@ }

@@ -0,4 +1,9 @@

/* global TWEEN */
import test from 'ava'
const { Easing, Tween, update, getAll, removeAll } = require('./bundled/Tween')
import { Easing, Tween, Timeline, update, getAll, removeAll } from './src'
import browserTestMiddleware from './withPage'
test('Events', t => {

@@ -14,3 +19,3 @@ let tween = new Tween({ x: 0 })

tween.on('start', () => {
t.log('Event [Start]: Was called successfully')
t.log('on:start was called successfully')
t.pass()

@@ -20,3 +25,3 @@ })

tween.on('update', () => {
t.log('Event [Update]: Was called successfully')
t.log('on:update was called successfully')
t.pass()

@@ -26,3 +31,3 @@ })

tween.on('repeat', () => {
t.log('Event [Repeat]: Was called successfully')
t.log('on:repeat was called successfully')
t.pass()

@@ -32,3 +37,3 @@ })

tween.on('reverse', () => {
t.log('Event [Reverse]: Was called successfully')
t.log('on:reverse was called successfully')
t.pass()

@@ -38,3 +43,3 @@ })

tween.on('complete', () => {
t.log('Event [Complete]: Was called successfully')
t.log('on:complete was called successfully')
t.pass()

@@ -204,1 +209,232 @@ })

})
test('Headless tests', browserTestMiddleware, (t, page) => {
return page.evaluate(() => {
const deepArrayCopy = arr => arr.map(child => Array.isArray(child)
? deepArrayCopy(child) : Object.keys(child) && Object.keys(child).length
? Object.assign({}, child) : child)
const tests = []
const obj = { x: 0, y: [50, 'String test 100'] }
const obj2 = { x: 0 }
const arr1 = [ [ 100 ], { f: 200 } ]
const tween1 = new TWEEN.Tween(obj)
.to({ x: 200, y: [100, 'String test 200'] }, 2000)
.on('start', () => {
tests.push({
method: 'log',
successMessage: 'on:start event works as excepted'
})
})
.on('update', (obj, elapsed) => {
tests.push({
method: 'log',
successMessage: 'on:update event works as excepted with elapsed ' + elapsed
})
})
.on('complete', () => {
tests.push({
method: 'log',
successMessage: 'on:complete event works as excepted'
})
})
const tween2 = new TWEEN.Tween(obj2).to({ x: 200 }, 4000).easing(TWEEN.Easing.Elastic.InOut)
const tween3 = new TWEEN.Tween(arr1).to([ [ 0 ], { f: 100 } ], 2000)
tween1.start(0)
tween2.start(0)
tween3.start(0)
tests.push({
method: 'is',
a: obj.x,
b: 0,
failMessage: 'ID: ObjX_24U'
})
tests.push({
method: 'is',
a: obj.y[0],
b: 50,
failMessage: 'ID: ObjY_25C'
})
tests.push({
method: 'is',
a: obj.y[1],
b: 'String test 100',
failMessage: 'ID: ObjY_26G'
})
tests.push({
method: 'is',
a: obj2.x,
b: 0,
failMessage: 'ID: ObjX_26Z'
})
tests.push({
method: 'is',
a: arr1[0][0],
b: 100,
failMessage: 'ID: ObjA_27L'
})
tests.push({
method: 'is',
a: arr1[1].f,
b: 200,
failMessage: 'ID: ObjF_27X'
})
TWEEN.update(1000)
tests.push({
method: 'is',
a: obj.x,
b: 100,
failMessage: 'There something wrong with number interpolation',
successMessage: 'Number interpolation works as excepted'
})
tests.push({
method: 'is',
a: obj.y[0],
b: 75,
failMessage: 'There something wrong with Array number interpolation',
successMessage: 'Array Number interpolation works as excepted'
})
tests.push({
method: 'is',
a: obj.y[1],
b: 'String test 150',
failMessage: 'There something wrong with Array string interpolation',
successMessage: 'Array string interpolation works as excepted'
})
tests.push({
method: 'not',
a: obj2.x,
b: 50,
failMessage: 'Easing not works properly or tween instance not handles easing function properly',
successMessage: 'Easing function works properly'
})
tests.push({
method: 'deepEqual',
a: deepArrayCopy(arr1),
b: [ [ 50 ], { f: 150 } ],
failMessage: 'Array-based tween failed due of internal processor/instance and/or something failed within core',
successMessage: 'Array-based tweens works properly'
})
TWEEN.update(2000)
tests.push({
method: 'is',
a: obj.x,
b: 200,
failMessage: 'ID: ObjX_32R'
})
tests.push({
method: 'is',
a: obj.y[0],
b: 100,
failMessage: 'ID: ObjY_33V'
})
tests.push({
method: 'is',
a: obj.y[1],
b: 'String test 200',
failMessage: 'ID: ObjY_33S'
})
tests.push({
method: 'not',
a: obj2.x,
b: 200,
failMessage: 'ID: ObjY_34I'
})
tests.push({
method: 'is',
a: arr1[0][0],
b: 0,
failMessage: 'ID: ObjA_34P'
})
tests.push({
method: 'is',
a: arr1[1].f,
b: 100,
failMessage: 'ID: ObjF_35T'
})
TWEEN.update(4000)
tests.push({
method: 'is',
a: obj2.x,
b: 200,
failMessage: 'ID: ObjY_36K'
})
return tests
}).then(tests => {
tests.map(({ method, a, b, failMessage, successMessage }) => {
if (method === 'log') {
t.log(successMessage)
} else {
t[method](a, b, failMessage)
successMessage && t.log(successMessage)
}
})
})
})
test('Timeline', (t) => {
const obj = { x: 0 }
const obj2 = { x: 0 }
const obj3 = { x: 0 }
const from = [obj, obj2, obj3]
const to = { x: 200 }
const tl = new Timeline({ duration: 1000, startTime: 0, stagger: 1000 }).to(from, to)
tl.on('start', () => {
t.pass()
t.log('on:start event works as excepted')
})
tl.on('update', (elapsed) => {
t.pass()
t.log('on:update event works as excepted with elapsed ' + elapsed)
})
tl.on('complete', () => {
t.pass()
t.log('on:complete event works as excepted')
})
tl.start(0)
t.is(obj.x, 0)
t.is(obj2.x, 0)
t.is(obj3.x, 0)
update(1000)
t.is(obj.x, 200)
t.is(obj2.x, 0)
t.is(obj3.x, 0)
update(2000)
t.is(obj.x, 200)
t.is(obj2.x, 200)
t.is(obj3.x, 0)
update(3000)
t.is(obj.x, 200)
t.is(obj2.x, 200)
t.is(obj3.x, 200)
update(4000)
t.is(obj.x, 200)
t.is(obj2.x, 200)
t.is(obj3.x, 200)
t.log('All values interpolation works as excepted')
})

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc