@jarvisniu/transition
Advanced tools
Comparing version 0.1.1 to 0.1.2
{ | ||
"name": "@jarvisniu/transition", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "CSS property transition for JavaScript", | ||
"main": "transition.js", | ||
"types": "transition.d.ts", | ||
"scripts": { | ||
@@ -7,0 +8,0 @@ "dev": "parcel demo/index.html --out-dir demo/dist", |
@@ -39,3 +39,3 @@ // transition - CSS property transition for JavaScript. | ||
function transition (target, props, options) { | ||
function transition(target, props, options) { | ||
options = options || {} | ||
@@ -52,3 +52,3 @@ options.duration = options.duration || DEFAULT_DURATION | ||
} | ||
Object.keys(props).forEach(prop => { | ||
Object.keys(props).forEach((prop) => { | ||
let startValue = target[prop] | ||
@@ -65,6 +65,6 @@ let targetVal = props[prop] | ||
// same target and prop only keep the last one | ||
transList = transList.filter(trans => { | ||
return trans.target !== target || trans.prop !== prop | ||
let existingTransIndex = transList.findIndex((trans) => { | ||
return trans.target === target && trans.prop === prop | ||
}) | ||
transList.push({ | ||
let newTrans = { | ||
target, | ||
@@ -80,3 +80,14 @@ prop, | ||
completed: false, | ||
}) | ||
} | ||
if (existingTransIndex > -1) { | ||
let existingTrans = transList[existingTransIndex] | ||
if (existingTrans.endValue !== targetVal) { | ||
transList = transList.filter((trans) => { | ||
return trans.target !== target || trans.prop !== prop | ||
}) | ||
transList.push(newTrans) | ||
} | ||
} else { | ||
transList.push(newTrans) | ||
} | ||
}) | ||
@@ -86,4 +97,4 @@ if (typeof options.onStart === 'function') options.onStart() | ||
function loop () { | ||
transList.forEach(trans => { | ||
function loop() { | ||
transList.forEach((trans) => { | ||
let currentTime = Date.now() | ||
@@ -101,3 +112,3 @@ let t = (currentTime - trans.startTime) / (trans.endTime - trans.startTime) | ||
}) | ||
transList = transList.filter(trans => !trans.completed) | ||
transList = transList.filter((trans) => !trans.completed) | ||
raf(loop) | ||
@@ -104,0 +115,0 @@ } |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
2
1
1
9495
7
163