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

cooljs

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cooljs - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

readme.md

46

engine.js
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

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