universal-transition
Advanced tools
Comparing version 0.6.4 to 0.6.5
@@ -85,3 +85,3 @@ module.exports = function(require, exports, module) { | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 2); | ||
/******/ return __webpack_require__(__webpack_require__.s = 0); | ||
/******/ }) | ||
@@ -99,5 +99,121 @@ /************************************************************************/ | ||
}); | ||
exports.default = transition; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _universalEnv = __webpack_require__(1); | ||
var _styleUnit = __webpack_require__(2); | ||
function transition(node, styles, options, callback) { | ||
if (!node) return; | ||
if (typeof options == 'function' || options == null) { | ||
callback = options; | ||
options = { | ||
timingFunction: 'ease', | ||
duration: 0, | ||
delay: 0 | ||
}; | ||
} | ||
for (var prop in styles) { | ||
styles[prop] = (0, _styleUnit.convertUnit)(styles[prop], prop); | ||
} | ||
if (_universalEnv.isWeex) { | ||
var animation = __weex_require__('@weex-module/animation'); | ||
animation.transition(node.ref, { | ||
styles: styles, | ||
timingFunction: options.timingFunction || 'linear', | ||
delay: options.delay || 0, | ||
duration: options.duration || 0, | ||
needLayout: options.needLayout || false | ||
}, callback || function () {}); | ||
} else if (_universalEnv.isWeb) { | ||
var duration = options.duration || 0; // ms | ||
var timingFunction = options.timingFunction || 'linear'; | ||
var delay = options.delay || 0; // ms | ||
var transitionValue = 'all ' + duration + 'ms ' + timingFunction + ' ' + delay + 'ms'; | ||
node.style.transition = transitionValue; | ||
node.style.webkitTransition = transitionValue; | ||
if (callback) { | ||
var transitionEndHandler = function transitionEndHandler(e) { | ||
e.stopPropagation(); | ||
node.removeEventListener('webkitTransitionEnd', transitionEndHandler); | ||
node.removeEventListener('transitionend', transitionEndHandler); | ||
node.style.transition = ''; | ||
node.style.webkitTransition = ''; | ||
callback(); | ||
}; | ||
node.addEventListener('webkitTransitionEnd', transitionEndHandler); | ||
node.addEventListener('transitionend', transitionEndHandler); | ||
} | ||
for (var key in styles) { | ||
// TODO add vendor prefix | ||
var value = styles[key]; | ||
node.style[key] = value; | ||
} | ||
} | ||
} | ||
module.exports = exports["default"]; | ||
/***/ }), | ||
/* 1 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = exports.isReactNative = exports.isWeex = exports.isNode = exports.isWeb = void 0; | ||
function _typeof(obj) { | ||
if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") { | ||
_typeof = function _typeof(obj) { | ||
return _typeof2(obj); | ||
}; | ||
} else { | ||
_typeof = function _typeof(obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj); | ||
}; | ||
} | ||
return _typeof(obj); | ||
} // https://www.w3.org/TR/html5/webappapis.html#dom-navigator-appcodename | ||
var isWeb = (typeof navigator === "undefined" ? "undefined" : _typeof(navigator)) === 'object' && (navigator.appCodeName === 'Mozilla' || navigator.product === 'Gecko'); | ||
exports.isWeb = isWeb; | ||
var isNode = typeof process !== 'undefined' && !!(process.versions && process.versions.node); | ||
exports.isNode = isNode; | ||
var isWeex = typeof callNative === 'function' || (typeof WXEnvironment === "undefined" ? "undefined" : _typeof(WXEnvironment)) === 'object' && WXEnvironment.platform !== 'Web'; | ||
exports.isWeex = isWeex; | ||
var isReactNative = typeof __fbBatchedBridgeConfig !== 'undefined'; | ||
exports.isReactNative = isReactNative; | ||
exports["default"] = module.exports; | ||
var _default = module.exports; | ||
exports.default = _default; | ||
/***/ }), | ||
/* 2 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.isRem = isRem; | ||
@@ -109,5 +225,22 @@ exports.calcRem = calcRem; | ||
exports.convertUnit = convertUnit; | ||
exports.default = void 0; | ||
function _typeof(obj) { | ||
if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") { | ||
_typeof = function _typeof(obj) { | ||
return _typeof2(obj); | ||
}; | ||
} else { | ||
_typeof = function _typeof(obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj); | ||
}; | ||
} | ||
return _typeof(obj); | ||
} | ||
/** | ||
* CSS properties which accept numbers but are not in units of "px". | ||
*/ | ||
var UNITLESS_NUMBER_PROPS = { | ||
@@ -144,20 +277,21 @@ animationIterationCount: true, | ||
}; | ||
var SUFFIX = 'rem'; | ||
var REM_REG = /[-+]?\d*\.?\d+rem/g; | ||
var IS_REM_REG = /\d+(rem|rpx)/; | ||
var REM_REG = /[-+]?\d*\.?\d+(rem|rpx)/g; | ||
var GLOBAL_REM_UNIT = '__global_rem_unit__'; | ||
var global = (typeof window === 'undefined' ? 'undefined' : _typeof(window)) === 'object' ? window : (typeof global === 'undefined' ? 'undefined' : _typeof(global)) === 'object' ? global : {}; | ||
// Default 1 rem to 1 px | ||
if (global[GLOBAL_REM_UNIT] == null) { | ||
global[GLOBAL_REM_UNIT] = 1; | ||
var global = (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' ? window : _typeof(global) === 'object' ? global : {}; // Default 1 rem to 1 px | ||
if (getRem() === undefined) { | ||
setRem(1); | ||
} | ||
/** | ||
* Is string contains rem | ||
* note: rpx is an alias to rem | ||
* @param {String} str | ||
* @returns {Boolean} | ||
*/ | ||
function isRem(str) { | ||
return typeof str === 'string' && str.indexOf(SUFFIX) !== -1; | ||
return IS_REM_REG.test(str); | ||
} | ||
/** | ||
@@ -169,5 +303,6 @@ * Calculate rem to pixels: '1.2rem' => 1.2 * rem | ||
*/ | ||
function calcRem(str) { | ||
var remUnit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : global[GLOBAL_REM_UNIT]; | ||
var remUnit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getRem(); | ||
return str.replace(REM_REG, function (rem) { | ||
@@ -191,3 +326,3 @@ return parseFloat(rem) * remUnit + 'px'; | ||
function convertUnit(val, prop) { | ||
var remUnit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : global[GLOBAL_REM_UNIT]; | ||
var remUnit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getRem(); | ||
@@ -202,104 +337,9 @@ if (prop && isUnitNumber(val, prop)) { | ||
} | ||
exports['default'] = module.exports; | ||
exports.default = module.exports; | ||
/***/ }), | ||
/* 1 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
exports["default"] = module.exports; | ||
var _default = module.exports; | ||
exports.default = _default; | ||
"use strict"; | ||
var _typeof2 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) { | ||
return typeof obj === "undefined" ? "undefined" : _typeof2(obj); | ||
} : function (obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof2(obj); | ||
}; | ||
// https://www.w3.org/TR/html5/webappapis.html#dom-navigator-appcodename | ||
var isWeb = exports.isWeb = (typeof navigator === 'undefined' ? 'undefined' : _typeof(navigator)) === 'object' && (navigator.appCodeName === 'Mozilla' || navigator.product === 'Gecko'); | ||
var isNode = exports.isNode = typeof process !== 'undefined' && !!(process.versions && process.versions.node); | ||
var isWeex = exports.isWeex = typeof callNative === 'function' || (typeof WXEnvironment === 'undefined' ? 'undefined' : _typeof(WXEnvironment)) === 'object' && WXEnvironment.platform !== 'Web'; | ||
var isReactNative = exports.isReactNative = typeof __fbBatchedBridgeConfig !== 'undefined'; | ||
exports['default'] = module.exports; | ||
exports.default = module.exports; | ||
/***/ }), | ||
/* 2 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = transition; | ||
var _universalEnv = __webpack_require__(1); | ||
var _styleUnit = __webpack_require__(0); | ||
function transition(node, styles, options, callback) { | ||
if (typeof options == 'function' || options == null) { | ||
callback = options; | ||
options = { | ||
timingFunction: 'ease', | ||
duration: 0, | ||
delay: 0 | ||
}; | ||
} | ||
for (var prop in styles) { | ||
styles[prop] = (0, _styleUnit.convertUnit)(styles[prop], prop); | ||
} | ||
if (_universalEnv.isWeex && node) { | ||
var animation = __weex_require__('@weex-module/animation'); | ||
animation.transition(node.ref, { | ||
styles: styles, | ||
timingFunction: options.timingFunction || 'linear', | ||
delay: options.delay || 0, | ||
duration: options.duration || 0, | ||
needLayout: options.needLayout || false | ||
}, callback || function () {}); | ||
} else if (_universalEnv.isWeb) { | ||
var duration = options.duration || 0; // ms | ||
var timingFunction = options.timingFunction || 'linear'; | ||
var delay = options.delay || 0; // ms | ||
var transitionValue = 'all ' + duration + 'ms ' + timingFunction + ' ' + delay + 'ms'; | ||
node.style.transition = transitionValue; | ||
node.style.webkitTransition = transitionValue; | ||
if (callback) { | ||
var transitionEndHandler = function transitionEndHandler(e) { | ||
e.stopPropagation(); | ||
node.removeEventListener('webkitTransitionEnd', transitionEndHandler); | ||
node.removeEventListener('transitionend', transitionEndHandler); | ||
node.style.transition = ''; | ||
node.style.webkitTransition = ''; | ||
callback(); | ||
}; | ||
node.addEventListener('webkitTransitionEnd', transitionEndHandler); | ||
node.addEventListener('transitionend', transitionEndHandler); | ||
} | ||
for (var key in styles) { | ||
// TODO add vendor prefix | ||
var value = styles[key]; | ||
node.style[key] = value; | ||
} | ||
} | ||
} | ||
module.exports = exports['default']; | ||
/***/ }) | ||
/******/ ])}};; | ||
//# sourceMappingURL=transition.factory.map |
@@ -107,3 +107,3 @@ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 2); | ||
/******/ return __webpack_require__(__webpack_require__.s = 0); | ||
/******/ }) | ||
@@ -121,5 +121,121 @@ /************************************************************************/ | ||
}); | ||
exports.default = transition; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _universalEnv = __webpack_require__(1); | ||
var _styleUnit = __webpack_require__(2); | ||
function transition(node, styles, options, callback) { | ||
if (!node) return; | ||
if (typeof options == 'function' || options == null) { | ||
callback = options; | ||
options = { | ||
timingFunction: 'ease', | ||
duration: 0, | ||
delay: 0 | ||
}; | ||
} | ||
for (var prop in styles) { | ||
styles[prop] = (0, _styleUnit.convertUnit)(styles[prop], prop); | ||
} | ||
if (_universalEnv.isWeex) { | ||
var animation = __weex_require__('@weex-module/animation'); | ||
animation.transition(node.ref, { | ||
styles: styles, | ||
timingFunction: options.timingFunction || 'linear', | ||
delay: options.delay || 0, | ||
duration: options.duration || 0, | ||
needLayout: options.needLayout || false | ||
}, callback || function () {}); | ||
} else if (_universalEnv.isWeb) { | ||
var duration = options.duration || 0; // ms | ||
var timingFunction = options.timingFunction || 'linear'; | ||
var delay = options.delay || 0; // ms | ||
var transitionValue = 'all ' + duration + 'ms ' + timingFunction + ' ' + delay + 'ms'; | ||
node.style.transition = transitionValue; | ||
node.style.webkitTransition = transitionValue; | ||
if (callback) { | ||
var transitionEndHandler = function transitionEndHandler(e) { | ||
e.stopPropagation(); | ||
node.removeEventListener('webkitTransitionEnd', transitionEndHandler); | ||
node.removeEventListener('transitionend', transitionEndHandler); | ||
node.style.transition = ''; | ||
node.style.webkitTransition = ''; | ||
callback(); | ||
}; | ||
node.addEventListener('webkitTransitionEnd', transitionEndHandler); | ||
node.addEventListener('transitionend', transitionEndHandler); | ||
} | ||
for (var key in styles) { | ||
// TODO add vendor prefix | ||
var value = styles[key]; | ||
node.style[key] = value; | ||
} | ||
} | ||
} | ||
module.exports = exports["default"]; | ||
/***/ }), | ||
/* 1 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = exports.isReactNative = exports.isWeex = exports.isNode = exports.isWeb = void 0; | ||
function _typeof(obj) { | ||
if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") { | ||
_typeof = function _typeof(obj) { | ||
return _typeof2(obj); | ||
}; | ||
} else { | ||
_typeof = function _typeof(obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj); | ||
}; | ||
} | ||
return _typeof(obj); | ||
} // https://www.w3.org/TR/html5/webappapis.html#dom-navigator-appcodename | ||
var isWeb = (typeof navigator === "undefined" ? "undefined" : _typeof(navigator)) === 'object' && (navigator.appCodeName === 'Mozilla' || navigator.product === 'Gecko'); | ||
exports.isWeb = isWeb; | ||
var isNode = typeof process !== 'undefined' && !!(process.versions && process.versions.node); | ||
exports.isNode = isNode; | ||
var isWeex = typeof callNative === 'function' || (typeof WXEnvironment === "undefined" ? "undefined" : _typeof(WXEnvironment)) === 'object' && WXEnvironment.platform !== 'Web'; | ||
exports.isWeex = isWeex; | ||
var isReactNative = typeof __fbBatchedBridgeConfig !== 'undefined'; | ||
exports.isReactNative = isReactNative; | ||
exports["default"] = module.exports; | ||
var _default = module.exports; | ||
exports.default = _default; | ||
/***/ }), | ||
/* 2 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.isRem = isRem; | ||
@@ -131,5 +247,22 @@ exports.calcRem = calcRem; | ||
exports.convertUnit = convertUnit; | ||
exports.default = void 0; | ||
function _typeof(obj) { | ||
if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") { | ||
_typeof = function _typeof(obj) { | ||
return _typeof2(obj); | ||
}; | ||
} else { | ||
_typeof = function _typeof(obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj); | ||
}; | ||
} | ||
return _typeof(obj); | ||
} | ||
/** | ||
* CSS properties which accept numbers but are not in units of "px". | ||
*/ | ||
var UNITLESS_NUMBER_PROPS = { | ||
@@ -166,20 +299,21 @@ animationIterationCount: true, | ||
}; | ||
var SUFFIX = 'rem'; | ||
var REM_REG = /[-+]?\d*\.?\d+rem/g; | ||
var IS_REM_REG = /\d+(rem|rpx)/; | ||
var REM_REG = /[-+]?\d*\.?\d+(rem|rpx)/g; | ||
var GLOBAL_REM_UNIT = '__global_rem_unit__'; | ||
var global = (typeof window === 'undefined' ? 'undefined' : _typeof(window)) === 'object' ? window : (typeof global === 'undefined' ? 'undefined' : _typeof(global)) === 'object' ? global : {}; | ||
// Default 1 rem to 1 px | ||
if (global[GLOBAL_REM_UNIT] == null) { | ||
global[GLOBAL_REM_UNIT] = 1; | ||
var global = (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' ? window : _typeof(global) === 'object' ? global : {}; // Default 1 rem to 1 px | ||
if (getRem() === undefined) { | ||
setRem(1); | ||
} | ||
/** | ||
* Is string contains rem | ||
* note: rpx is an alias to rem | ||
* @param {String} str | ||
* @returns {Boolean} | ||
*/ | ||
function isRem(str) { | ||
return typeof str === 'string' && str.indexOf(SUFFIX) !== -1; | ||
return IS_REM_REG.test(str); | ||
} | ||
/** | ||
@@ -191,5 +325,6 @@ * Calculate rem to pixels: '1.2rem' => 1.2 * rem | ||
*/ | ||
function calcRem(str) { | ||
var remUnit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : global[GLOBAL_REM_UNIT]; | ||
var remUnit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getRem(); | ||
return str.replace(REM_REG, function (rem) { | ||
@@ -213,3 +348,3 @@ return parseFloat(rem) * remUnit + 'px'; | ||
function convertUnit(val, prop) { | ||
var remUnit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : global[GLOBAL_REM_UNIT]; | ||
var remUnit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getRem(); | ||
@@ -224,104 +359,9 @@ if (prop && isUnitNumber(val, prop)) { | ||
} | ||
exports['default'] = module.exports; | ||
exports.default = module.exports; | ||
/***/ }), | ||
/* 1 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
exports["default"] = module.exports; | ||
var _default = module.exports; | ||
exports.default = _default; | ||
"use strict"; | ||
var _typeof2 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) { | ||
return typeof obj === "undefined" ? "undefined" : _typeof2(obj); | ||
} : function (obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof2(obj); | ||
}; | ||
// https://www.w3.org/TR/html5/webappapis.html#dom-navigator-appcodename | ||
var isWeb = exports.isWeb = (typeof navigator === 'undefined' ? 'undefined' : _typeof(navigator)) === 'object' && (navigator.appCodeName === 'Mozilla' || navigator.product === 'Gecko'); | ||
var isNode = exports.isNode = typeof process !== 'undefined' && !!(process.versions && process.versions.node); | ||
var isWeex = exports.isWeex = typeof callNative === 'function' || (typeof WXEnvironment === 'undefined' ? 'undefined' : _typeof(WXEnvironment)) === 'object' && WXEnvironment.platform !== 'Web'; | ||
var isReactNative = exports.isReactNative = typeof __fbBatchedBridgeConfig !== 'undefined'; | ||
exports['default'] = module.exports; | ||
exports.default = module.exports; | ||
/***/ }), | ||
/* 2 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = transition; | ||
var _universalEnv = __webpack_require__(1); | ||
var _styleUnit = __webpack_require__(0); | ||
function transition(node, styles, options, callback) { | ||
if (typeof options == 'function' || options == null) { | ||
callback = options; | ||
options = { | ||
timingFunction: 'ease', | ||
duration: 0, | ||
delay: 0 | ||
}; | ||
} | ||
for (var prop in styles) { | ||
styles[prop] = (0, _styleUnit.convertUnit)(styles[prop], prop); | ||
} | ||
if (_universalEnv.isWeex && node) { | ||
var animation = __weex_require__('@weex-module/animation'); | ||
animation.transition(node.ref, { | ||
styles: styles, | ||
timingFunction: options.timingFunction || 'linear', | ||
delay: options.delay || 0, | ||
duration: options.duration || 0, | ||
needLayout: options.needLayout || false | ||
}, callback || function () {}); | ||
} else if (_universalEnv.isWeb) { | ||
var duration = options.duration || 0; // ms | ||
var timingFunction = options.timingFunction || 'linear'; | ||
var delay = options.delay || 0; // ms | ||
var transitionValue = 'all ' + duration + 'ms ' + timingFunction + ' ' + delay + 'ms'; | ||
node.style.transition = transitionValue; | ||
node.style.webkitTransition = transitionValue; | ||
if (callback) { | ||
var transitionEndHandler = function transitionEndHandler(e) { | ||
e.stopPropagation(); | ||
node.removeEventListener('webkitTransitionEnd', transitionEndHandler); | ||
node.removeEventListener('transitionend', transitionEndHandler); | ||
node.style.transition = ''; | ||
node.style.webkitTransition = ''; | ||
callback(); | ||
}; | ||
node.addEventListener('webkitTransitionEnd', transitionEndHandler); | ||
node.addEventListener('transitionend', transitionEndHandler); | ||
} | ||
for (var key in styles) { | ||
// TODO add vendor prefix | ||
var value = styles[key]; | ||
node.style[key] = value; | ||
} | ||
} | ||
} | ||
module.exports = exports['default']; | ||
/***/ }) | ||
/******/ ])});; | ||
//# sourceMappingURL=transition.map |
@@ -1,2 +0,2 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define)define("universal-transition",function(n,t,o){o.exports=e()});else{("undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:this).UniversalTransition=e()}}(function(){return function(e){var n={};function t(o){if(n[o])return n[o].exports;var i=n[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,t),i.l=!0,i.exports}return t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:o})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(t.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var i in e)t.d(o,i,function(n){return e[n]}.bind(null,i));return o},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=2)}([function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};n.isRem=a,n.calcRem=d,n.getRem=function(){return l[f]},n.setRem=function(e){l[f]=e},n.isUnitNumber=s,n.convertUnit=function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:l[f];if(n&&s(e,n))return e*t+"px";if(a(e))return d(e,t);return e};var i={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridColumn:!0,fontWeight:!0,lineClamp:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,lines:!0},r="rem",u=/[-+]?\d*\.?\d+rem/g,f="__global_rem_unit__",l="object"===("undefined"==typeof window?"undefined":o(window))?window:"object"===(void 0===l?"undefined":o(l))?l:{};function a(e){return"string"==typeof e&&-1!==e.indexOf(r)}function d(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:l[f];return e.replace(u,function(e){return parseFloat(e)*n+"px"})}function s(e,n){return"number"==typeof e&&!i[n]}null==l[f]&&(l[f]=1),n.default=e.exports,n.default=e.exports},function(e,n,t){"use strict";var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};Object.defineProperty(n,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"===o(Symbol.iterator)?function(e){return void 0===e?"undefined":o(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":o(e)};n.isWeb="object"===("undefined"==typeof navigator?"undefined":i(navigator))&&("Mozilla"===navigator.appCodeName||"Gecko"===navigator.product),n.isNode="undefined"!=typeof process&&!(!process.versions||!process.versions.node),n.isWeex="function"==typeof callNative||"object"===("undefined"==typeof WXEnvironment?"undefined":i(WXEnvironment))&&"Web"!==WXEnvironment.platform,n.isReactNative="undefined"!=typeof __fbBatchedBridgeConfig;n.default=e.exports,n.default=e.exports},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,n,t,r){"function"!=typeof t&&null!=t||(r=t,t={timingFunction:"ease",duration:0,delay:0});for(var u in n)n[u]=(0,i.convertUnit)(n[u],u);if(o.isWeex&&e){var f=__weex_require__("@weex-module/animation");f.transition(e.ref,{styles:n,timingFunction:t.timingFunction||"linear",delay:t.delay||0,duration:t.duration||0,needLayout:t.needLayout||!1},r||function(){})}else if(o.isWeb){var l=t.duration||0,a=t.timingFunction||"linear",d=t.delay||0,s="all "+l+"ms "+a+" "+d+"ms";if(e.style.transition=s,e.style.webkitTransition=s,r){var c=function n(t){t.stopPropagation(),e.removeEventListener("webkitTransitionEnd",n),e.removeEventListener("transitionend",n),e.style.transition="",e.style.webkitTransition="",r()};e.addEventListener("webkitTransitionEnd",c),e.addEventListener("transitionend",c)}for(var y in n){var p=n[y];e.style[y]=p}}};var o=t(1),i=t(0);e.exports=n.default}])}); | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define)define("universal-transition",function(t,n,o){o.exports=e()});else{("undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:this).UniversalTransition=e()}}(function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,n,i){if(!e)return;"function"!=typeof n&&null!=n||(i=n,n={timingFunction:"ease",duration:0,delay:0});for(var u in t)t[u]=(0,r.convertUnit)(t[u],u);if(o.isWeex){var f=__weex_require__("@weex-module/animation");f.transition(e.ref,{styles:t,timingFunction:n.timingFunction||"linear",delay:n.delay||0,duration:n.duration||0,needLayout:n.needLayout||!1},i||function(){})}else if(o.isWeb){var l=n.duration||0,a=n.timingFunction||"linear",d=n.delay||0,s="all "+l+"ms "+a+" "+d+"ms";if(e.style.transition=s,e.style.webkitTransition=s,i){var c=function t(n){n.stopPropagation(),e.removeEventListener("webkitTransitionEnd",t),e.removeEventListener("transitionend",t),e.style.transition="",e.style.webkitTransition="",i()};e.addEventListener("webkitTransitionEnd",c),e.addEventListener("transitionend",c)}for(var y in t){var p=t[y];e.style[y]=p}}};var o=n(1),r=n(2);e.exports=t.default},function(e,t,n){"use strict";function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e){return(r="function"==typeof Symbol&&"symbol"===o(Symbol.iterator)?function(e){return o(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":o(e)})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.isReactNative=t.isWeex=t.isNode=t.isWeb=void 0;var i="object"===("undefined"==typeof navigator?"undefined":r(navigator))&&("Mozilla"===navigator.appCodeName||"Gecko"===navigator.product);t.isWeb=i;var u="undefined"!=typeof process&&!(!process.versions||!process.versions.node);t.isNode=u;var f="function"==typeof callNative||"object"===("undefined"==typeof WXEnvironment?"undefined":r(WXEnvironment))&&"Web"!==WXEnvironment.platform;t.isWeex=f;var l="undefined"!=typeof __fbBatchedBridgeConfig;t.isReactNative=l,t.default=e.exports;var a=e.exports;t.default=a},function(e,t,n){"use strict";function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e){return(r="function"==typeof Symbol&&"symbol"===o(Symbol.iterator)?function(e){return o(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":o(e)})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.isRem=d,t.calcRem=s,t.getRem=c,t.setRem=y,t.isUnitNumber=p,t.convertUnit=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:c();if(t&&p(e,t))return e*n+"px";if(d(e))return s(e,n);return e},t.default=void 0;var i={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridColumn:!0,fontWeight:!0,lineClamp:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,lines:!0},u=/\d+(rem|rpx)/,f=/[-+]?\d*\.?\d+(rem|rpx)/g,l="__global_rem_unit__",a="object"===("undefined"==typeof window?"undefined":r(window))?window:"object"===r(a)?a:{};function d(e){return u.test(e)}function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:c();return e.replace(f,function(e){return parseFloat(e)*t+"px"})}function c(){return a[l]}function y(e){a[l]=e}function p(e,t){return"number"==typeof e&&!i[t]}void 0===c()&&y(1),t.default=e.exports;var b=e.exports;t.default=b}])}); | ||
//# sourceMappingURL=transition.min.map |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -8,7 +8,9 @@ Object.defineProperty(exports, "__esModule", { | ||
var _universalEnv = require('universal-env'); | ||
var _universalEnv = require("universal-env"); | ||
var _styleUnit = require('style-unit'); | ||
var _styleUnit = require("style-unit"); | ||
function transition(node, styles, options, callback) { | ||
if (!node) return; | ||
if (typeof options == 'function' || options == null) { | ||
@@ -27,4 +29,5 @@ callback = options; | ||
if (_universalEnv.isWeex && node) { | ||
if (_universalEnv.isWeex) { | ||
var animation = __weex_require__('@weex-module/animation'); | ||
animation.transition(node.ref, { | ||
@@ -39,6 +42,7 @@ styles: styles, | ||
var duration = options.duration || 0; // ms | ||
var timingFunction = options.timingFunction || 'linear'; | ||
var delay = options.delay || 0; // ms | ||
var transitionValue = 'all ' + duration + 'ms ' + timingFunction + ' ' + delay + 'ms'; | ||
node.style.transition = transitionValue; | ||
@@ -56,2 +60,3 @@ node.style.webkitTransition = transitionValue; | ||
}; | ||
node.addEventListener('webkitTransitionEnd', transitionEndHandler); | ||
@@ -68,2 +73,3 @@ node.addEventListener('transitionend', transitionEndHandler); | ||
} | ||
module.exports = exports['default']; | ||
module.exports = exports["default"]; |
{ | ||
"name": "universal-transition", | ||
"version": "0.6.4", | ||
"version": "0.6.5", | ||
"description": "A universal transition API.", | ||
@@ -16,5 +16,5 @@ "license": "BSD-3-Clause", | ||
"dependencies": { | ||
"style-unit": "^0.6.4", | ||
"universal-env": "^0.6.4" | ||
"style-unit": "^0.6.5", | ||
"universal-env": "^0.6.5" | ||
} | ||
} |
@@ -5,2 +5,4 @@ import {isWeex, isWeb} from 'universal-env'; | ||
export default function transition(node, styles, options, callback) { | ||
if (!node) return; | ||
if (typeof options == 'function' || options == null) { | ||
@@ -19,3 +21,3 @@ callback = options; | ||
if (isWeex && node) { | ||
if (isWeex) { | ||
const animation = __weex_require__('@weex-module/animation'); | ||
@@ -22,0 +24,0 @@ animation.transition(node.ref, { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
99273
16
1100
2
2
Updatedstyle-unit@^0.6.5
Updateduniversal-env@^0.6.5