Socket
Socket
Sign inDemoInstall

animates

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

animates - npm Package Compare versions

Comparing version 0.0.0 to 0.0.1

lib/defaults.js

27

lib/animates.js

@@ -0,21 +1,12 @@

var css = require('./css')
var defaults = require('./defaults')
var transition = require('./transition')
var defer = require('./defer')
var css = require('./css')
module.exports = function animates (el, start, end, opts) {
opts = opts || {}
clearTimeout(el._animates)
if (typeof opts.speed === 'undefined') opts.speed = 200
el.style.transition = 'none'
css(el, start)
defer(doTransition)
function doTransition () {
el.style.transition = transition(end, opts.speed, opts.easing, opts.delay)
css(el, end)
el._animates = setTimeout(function finish () {
el.style.transition = 'none'
delete el._animates
}, Number(opts.speed || 200))
}
module.exports = function animates (el, end, opts) {
opts = defaults(opts)
el.style.transition = transition(end, opts.speed, opts.easing, opts.delay)
css(el, end)
return setTimeout(function finish () {
el.style.transition = 'none'
}, opts.speed)
}

@@ -10,3 +10,2 @@ var seconds = require('./seconds')

function tidbit (prop, speed, easing, delay) {
speed = speed || 200
var bits = [prop, seconds(speed)]

@@ -13,0 +12,0 @@ if (easing) bits.push(easing)

{
"name": "animates",
"version": "0.0.0",
"version": "0.0.1",
"description": "A small css3 animation lib inspired by jquery/animate",

@@ -5,0 +5,0 @@ "main": "lib/animates.js",

@@ -1,10 +0,29 @@

/* globals describe it */
var camel = require('../lib/camel')
/* globals describe beforeEach it */
var animates = require('../lib/animates')
var expect = require('chai').expect
describe('camel', function () {
it('should camel case style declarations', function () {
expect(camel('margin-left')).to.eq('marginLeft')
expect(camel('padding-top')).to.eq('paddingTop')
describe('animate', function () {
var el
beforeEach(function () {
el = document.createElement('div')
el.setAttribute('style', 'width: 20px; height: 20px; background: black;')
document.body.appendChild(el)
})
it('should camel case style declarations', function (done) {
animates(el, { opacity: 0 }, { speed: 100 })
setTimeout(middle, 0)
setTimeout(end, 200)
function middle () {
expect(el.style.transition).to.eql('opacity 0.1s')
}
function end () {
expect(el.style.opacity).to.eql('0')
expect(el.style.transition).to.eql('none')
done()
}
})
})
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