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

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 1.0.2 to 1.0.3

lib/uncamel.js

8

lib/animates.js

@@ -1,6 +0,6 @@

var css = require('./css')
var applyCss = require('./css')
var defaults = require('./defaults')
var transition = require('./transition')
module.exports = function animates (el, end, opts) {
module.exports = function animates (el, css, opts) {
opts = defaults(opts)

@@ -11,4 +11,4 @@ setTimeout(start, 1)

function start () {
el.style.transition = transition(opts.speed, opts.easing, opts.delay)
css(el, end)
el.style.transition = transition(css, opts.speed, opts.easing, opts.delay)
applyCss(el, css)
}

@@ -15,0 +15,0 @@ function finish () {

var seconds = require('./seconds')
var uncamel = require('./uncamel')
module.exports = function transition (speed, easing, delay) {
var str = 'all ' + seconds(speed)
if (easing) str += ' ' + easing
if (delay) str += ' ' + seconds(delay)
return str
module.exports = function transition (props, speed, easing, delay) {
var transitions = []
var suffix = seconds(speed)
if (easing) suffix += ' ' + easing
if (delay) suffix += ' ' + seconds(delay)
for (var prop in props) if (props.hasOwnProperty(prop)) transitions.push(uncamel(prop) + ' ' + suffix)
return transitions.join(', ')
}
{
"name": "animates",
"version": "1.0.2",
"version": "1.0.3",
"description": "A tiny, performant replacement for jquery/animate using css3",

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

@@ -16,7 +16,7 @@ /* globals describe beforeEach it */

animates(el, { opacity: 0 }, { speed: 100 })
setTimeout(middle, 0)
setTimeout(middle, 10)
setTimeout(end, 200)
function middle () {
expect(el.style.transition).to.eql('all 0.1s')
expect(el.style.transition).to.eql('opacity 0.1s')
}

@@ -23,0 +23,0 @@

@@ -7,9 +7,15 @@ /* globals describe it */

it('should create transition strings', function () {
expect(transition(100, 'linear', 1000)).to.eq('all 0.1s linear 1s')
expect(transition({ top: 1 }, 100, 'linear', 1000)).to.eq('top 0.1s linear 1s')
})
it('should create a transition string per property', function () {
expect(transition({ top: 1, left: 2 }, 100, 'linear', 1000)).to.eq('top 0.1s linear 1s, left 0.1s linear 1s')
})
it('should treat easing and delay as optional', function () {
expect(transition(100)).to.eq('all 0.1s')
expect(transition(100, 'linear')).to.eq('all 0.1s linear')
expect(transition(100, null, 1000)).to.eq('all 0.1s 1s')
expect(transition({ opacity: 1 }, 100)).to.eq('opacity 0.1s')
expect(transition({ opacity: 1 }, 100, 'linear')).to.eq('opacity 0.1s linear')
expect(transition({ opacity: 1 }, 100, null, 1000)).to.eq('opacity 0.1s 1s')
})
it('should uncamel props', function () {
expect(transition({ marginLeft: 1 }, 100)).to.eq('margin-left 0.1s')
})
})
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