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.2 to 1.0.3

.travis.yml

29

engine.js

@@ -38,2 +38,3 @@ import * as utils from './utils'

this.instancesObj[this.defaultLayer] = []
this.instancesReactionArr = []
this.utils = utils

@@ -121,2 +122,16 @@ this.customVariable = {}

triggerReaction(x, y) {
let calX = x
let calY = y
if (this.highResolution) {
calX *= 2
calY *= 2
}
this.instancesReactionArr.forEach((i) => {
if (!i.visible) return
if (calX >= i.x && calX<= i.x + i.width && calY >= i.y && calY<= i.y + i.height) {
i.trigger(i, this)
}
})
}

@@ -278,2 +293,9 @@ addAudio(name, src, retry = 0) {

})
this.instancesReactionArr.forEach((i) => {
if (!i.visible) return
this.ctx.strokeStyle = 'red'
this.ctx.beginPath()
this.ctx.rect(i.x, i.y, i.width, i.height)
this.ctx.stroke()
})
}

@@ -414,2 +436,3 @@

this.instancesObj[layer].push(instance)
if (instance.trigger) this.instancesReactionArr.push(instance)
}

@@ -422,4 +445,8 @@

removeInstance(name, layer = this.defaultLayer) {
if (this.getInstance(name, layer)) {
const instance = this.getInstance(name, layer)
if (instance) {
this.instancesObj[layer] = this.instancesObj[layer].filter(i => i.name !== name)
if (instance.trigger) {
this.instancesReactionArr = this.instancesReactionArr.filter(i => i.name !== name)
}
}

@@ -426,0 +453,0 @@ }

3

instance.js
export default class Instance {
constructor(option = {}) {
const { name, painter, action } = option
const { name, painter, action, trigger } = option
this.name = name

@@ -16,2 +16,3 @@ this.x = 0

this.action = action || null
this.trigger = trigger || null
this.ready = false

@@ -18,0 +19,0 @@ }

{
"name": "cooljs",
"version": "1.0.2",
"version": "1.0.3",
"description": "cooljs",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo ok"
},

@@ -9,0 +9,0 @@ "repository": {

@@ -1,1 +0,2 @@

# cool javascript
# cool javascript

@@ -1,2 +0,2 @@

export const getCurrentTime = () => (+new Date())
export const getCurrentTime = () => (performance.now() * 1000)

@@ -3,0 +3,0 @@ export const random = (min, max) => (Math.random() * (max - min)) + min

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