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

metal-anim

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metal-anim - npm Package Compare versions

Comparing version 1.0.0-rc.2 to 1.0.0-rc.3

151

lib/Anim.js

@@ -7,4 +7,2 @@ 'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _metal = require('metal');

@@ -25,95 +23,88 @@

_createClass(Anim, null, [{
key: 'emulateEnd',
/**
* Emulates animation or transition end event, the end event with longer
* duration will be used by the emulation. If they have the same value,
* transitionend will be emulated.
* @param {!Element} element
* @param {number=} opt_durationMs
* @return {!Object} Object containing `abort` function.
*/
/**
* Emulates animation or transition end event, the end event with longer
* duration will be used by the emulation. If they have the same value,
* transitionend will be emulated.
* @param {!Element} element
* @param {number=} opt_durationMs
* @return {!Object} Object containing `abort` function.
*/
value: function emulateEnd(element, opt_durationMs) {
if (this.getComputedDurationMs(element, 'animation') > this.getComputedDurationMs(element, 'transition')) {
return this.emulateEnd_(element, 'animation', opt_durationMs);
} else {
return this.emulateEnd_(element, 'transition', opt_durationMs);
}
Anim.emulateEnd = function emulateEnd(element, opt_durationMs) {
if (this.getComputedDurationMs(element, 'animation') > this.getComputedDurationMs(element, 'transition')) {
return this.emulateEnd_(element, 'animation', opt_durationMs);
} else {
return this.emulateEnd_(element, 'transition', opt_durationMs);
}
};
/**
* Emulates animation end event. If `opt_durationMs` not specified the value
* will read from computed style for animation-duration.
* @param {!Element} element
* @param {number=} opt_durationMs
* @return {!Object} Object containing `abort` function.
*/
/**
* Emulates animation end event. If `opt_durationMs` not specified the value
* will read from computed style for animation-duration.
* @param {!Element} element
* @param {number=} opt_durationMs
* @return {!Object} Object containing `abort` function.
*/
}, {
key: 'emulateAnimationEnd',
value: function emulateAnimationEnd(element, opt_durationMs) {
return this.emulateEnd_(element, 'animation', opt_durationMs);
}
/**
* Emulates transition end event. If `opt_durationMs` not specified the
* value will read from computed style for transition-duration.
* @param {!Element} element
* @param {number=} opt_durationMs
* @return {!Object} Object containing `abort` function.
*/
Anim.emulateAnimationEnd = function emulateAnimationEnd(element, opt_durationMs) {
return this.emulateEnd_(element, 'animation', opt_durationMs);
};
}, {
key: 'emulateTransitionEnd',
value: function emulateTransitionEnd(element, opt_durationMs) {
this.emulateEnd_(element, 'transition', opt_durationMs);
}
/**
* Emulates transition end event. If `opt_durationMs` not specified the
* value will read from computed style for transition-duration.
* @param {!Element} element
* @param {number=} opt_durationMs
* @return {!Object} Object containing `abort` function.
*/
/**
* Emulates transition or animation end.
* @param {!Element} element
* @param {string} type
* @param {number=} opt_durationMs
* @return {!Object} Object containing `abort` function.
* @protected
*/
}, {
key: 'emulateEnd_',
value: function emulateEnd_(element, type, opt_durationMs) {
var duration = opt_durationMs;
if (!_metal2.default.isDef(opt_durationMs)) {
duration = this.getComputedDurationMs(element, type);
}
Anim.emulateTransitionEnd = function emulateTransitionEnd(element, opt_durationMs) {
this.emulateEnd_(element, 'transition', opt_durationMs);
};
var delayed = setTimeout(function () {
_metalDom.dom.triggerEvent(element, _metalDom.features.checkAnimationEventName()[type]);
}, duration);
/**
* Emulates transition or animation end.
* @param {!Element} element
* @param {string} type
* @param {number=} opt_durationMs
* @return {!Object} Object containing `abort` function.
* @protected
*/
var abort = function abort() {
clearTimeout(delayed);
hoistedEvtHandler.removeListener();
};
var hoistedEvtHandler = _metalDom.dom.once(element, type + 'end', abort);
return {
abort: abort
};
Anim.emulateEnd_ = function emulateEnd_(element, type, opt_durationMs) {
var duration = opt_durationMs;
if (!_metal2.default.isDef(opt_durationMs)) {
duration = this.getComputedDurationMs(element, type);
}
/**
* Gets computed style duration for duration.
* @param {!Element} element
* @param {string} type
* @return {number} The computed duration in milliseconds.
*/
var delayed = setTimeout(function () {
_metalDom.dom.triggerEvent(element, _metalDom.features.checkAnimationEventName()[type]);
}, duration);
}, {
key: 'getComputedDurationMs',
value: function getComputedDurationMs(element, type) {
return (parseFloat(window.getComputedStyle(element, null).getPropertyValue(type + '-duration')) || 0) * 1000;
}
}]);
var abort = function abort() {
clearTimeout(delayed);
hoistedEvtHandler.removeListener();
};
var hoistedEvtHandler = _metalDom.dom.once(element, type + 'end', abort);
return {
abort: abort
};
};
/**
* Gets computed style duration for duration.
* @param {!Element} element
* @param {string} type
* @return {number} The computed duration in milliseconds.
*/
Anim.getComputedDurationMs = function getComputedDurationMs(element, type) {
return (parseFloat(window.getComputedStyle(element, null).getPropertyValue(type + '-duration')) || 0) * 1000;
};
return Anim;

@@ -120,0 +111,0 @@ }();

{
"name": "metal-anim",
"version": "1.0.0-rc.2",
"version": "1.0.0-rc.3",
"description": "Metal's animation utility",

@@ -19,3 +19,3 @@ "license": "BSD",

"scripts": {
"compile": "babel --presets es2015 -d lib/ src/",
"compile": "babel --presets metal -d lib/ src/",
"prepublish": "npm run compile",

@@ -33,3 +33,3 @@ "test": "gulp test"

"babel-cli": "^6.4.5",
"babel-preset-es2015": "^6.3.13",
"babel-preset-metal": "^4.0.0",
"gulp": "^3.8.11",

@@ -36,0 +36,0 @@ "gulp-metal": "^1.0.0"

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