Comparing version 1.0.1 to 1.0.2
import * as utils from './utils' | ||
import Tween from './tween' | ||
@@ -334,3 +335,6 @@ const { requestAnimationFrameTool, isFunction, isTouchDevice } = utils | ||
getTimeMovement(name, process, before, after) { | ||
getTimeMovement(name, value, render, option = {}) { | ||
const { before, after } = option | ||
const timingFunc = Tween[option.easing || 'linear'] | ||
const movementInstanceName = option.name || 'default' | ||
const movement = this.timeMovement[name] | ||
@@ -342,9 +346,29 @@ if (!movement) { | ||
this.timeMovementStartArr.push(name) | ||
before && before(movement.store) | ||
movement.store[movementInstanceName] = [] | ||
value.forEach((v) => { | ||
movement.store[movementInstanceName].push({ | ||
start: parseFloat(v[0]), | ||
end: parseFloat(v[1]) | ||
}) | ||
}) | ||
before && before() | ||
} | ||
const processRender = (lastRender = false) => { | ||
const { duration } = movement | ||
let t = duration | ||
if (!lastRender) { | ||
const currentTime = this.utils.getCurrentTime() | ||
const { startTime } = movement | ||
t = currentTime - startTime | ||
} | ||
const values = movement.store[movementInstanceName] | ||
.map(v => timingFunc(t, v.start, v.end - v.start, duration)) | ||
render.apply(this, values) | ||
} | ||
if (this.checkTimeMovement(name)) { | ||
process() | ||
processRender() | ||
} else { | ||
this.timeMovementFinishArr.push(name) | ||
after && after(movement.store) | ||
processRender(true) | ||
after && after() | ||
} | ||
@@ -355,14 +379,12 @@ } | ||
const movement = this.timeMovement[name] || {} | ||
return this.utils.getCurrentTime() <= movement.time | ||
return this.utils.getCurrentTime() <= movement.endTime | ||
} | ||
setTimeMovement(name, duration) { | ||
const currentTime = this.utils.getCurrentTime() | ||
this.timeMovement[name] = { | ||
time: this.utils.getCurrentTime() + duration, | ||
store: { | ||
pixelsPerFrame: distance => ( | ||
(distance * duration) / 1000 | ||
), | ||
state: [] | ||
} | ||
startTime: currentTime, | ||
endTime: currentTime + duration, | ||
duration, | ||
store: {} | ||
} | ||
@@ -369,0 +391,0 @@ } |
{ | ||
"name": "cooljs", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "cooljs", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
16006
8
582
1
1
0