multimediaobject
Version:
Multimediaobject library
1,224 lines (1,120 loc) • 99.9 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.MultimediaObject = factory());
}(this, (function () { 'use strict';
/* eslint-disable */
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
var raf = (function () {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];
}
if (!window.requestAnimationFrame) {
window.requestAnimationFrame = function (callback) {
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout(function () {
callback(currTime + timeToCall);
}, timeToCall);
lastTime = currTime + timeToCall;
return id;
};
}
if (!window.cancelAnimationFrame) {
window.cancelAnimationFrame = function (id) {
clearTimeout(id);
};
}
});
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 classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
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;
};
}();
/* eslint-disable */
var type = function type(obj) {
var text = obj.constructor.toString();
return text.match(/function (.*)\(/)[1];
};
var Set = function () {
function Set(array) {
classCallCheck(this, Set);
this.obj = {};
if (array) {
this.add(array);
}
}
createClass(Set, [{
key: 'contains',
value: function contains(v) {
return this.obj[v] === 1;
}
}, {
key: 'add',
value: function add(array) {
var i = void 0;
var len = void 0;
var v = void 0;
if (typeof array !== 'string' && typeof array !== 'number' && type(array).indexOf('Array') < 0) {
throw new Error('you can only add an array, a string or a number');
}
if (typeof array === 'string' || typeof array === 'number') {
this.obj[array] = 1;
} else {
for (i = 0, len = array.length; i < len; i++) {
v = array[i];
this.obj[v] = 1;
}
}
}
}]);
return Set;
}();
var pxPropertiesArray = ['baselineShift', 'border', 'backgroundPositionX', 'backgroundPositionY', 'borderBottom', 'borderBottomLeftRadius', 'borderBottomRightRadius', 'borderBottomWidth', 'borderImageOutset', 'borderImageWidth', 'borderLeft', 'borderLeftWidth', 'borderRadius', 'borderRight', 'borderRightWidth', 'borderSpacing', 'borderTop', 'borderTopLeftRadius', 'borderTopRightRadius', 'borderTopWidth', 'borderWidth', 'bottom', 'columnGap', 'columnRule', 'columnRuleWidth', 'columnWidth', 'cx', 'cy', 'flexBasis', 'fontSize', 'left', 'letterSpacing', 'lineHeight', 'marginBottom', 'marginLeft', 'marginRight', 'marginTop', 'maxHeight', 'maxWidth', 'minHeight', 'minWidth', 'motion', 'offset', 'offsetDistance', 'outlineOffset', 'outlineWidth', 'paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop', 'perspective', 'r', 'right', 'rx', 'ry', 'shapeMargin', 'size', 'strokeDasharray', 'strokeDashoffset', 'strokeWidth', 'tabSize', 'textIndent', 'top', 'width', 'height', 'wordSpacing', 'x', 'y', 'baseline-shift', 'border-bottom', 'border-bottom-left-radius', 'border-bottom-right-radius', 'border-bottom-width', 'border-image-outset', 'border-image-width', 'border-left', 'border-left-width', 'border-radius', 'border-right', 'border-right-width', 'border-spacing', 'border-top', 'border-top-left-radius', 'border-top-right-radius', 'border-top-width', 'border-width', 'column-gap', 'column-rule', 'column-rule-width', 'column-width', 'flex-basis', 'font-size', 'letter-spacing', 'line-height', 'margin-bottom', 'margin-left', 'margin-right', 'margin-top', 'max-height', 'max-width', 'min-height', 'min-width', 'offset-distance', 'padding-bottom', 'padding-left', 'padding-right', 'padding-top', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-width', 'tab-size', 'text-indent', 'word-spacing', 'translateX', 'translateY', 'translateZ', 'translate-x', 'translate-y', 'translate-z', 'translate', 'background-position-x', 'background-position-y'];
var stylePropertiesArray = ['background', 'flex', 'flexGrow', 'flexShrink', 'objectPosition', 'transformOrigin', 'alignContent', 'alignItems', 'alignSelf', 'alignmentBaseline', 'all', 'animation', 'animationDelay', 'animationDirection', 'animationDuration', 'animationFillMode', 'animationIterationCount', 'animationName', 'animationPlayState', 'animationTimingFunction', 'backfaceVisibility', 'background', 'backgroundAttachment', 'backgroundBlendMode', 'backgroundClip', 'backgroundColor', 'backgroundImage', 'backgroundOrigin', 'backgroundPosition', 'backgroundRepeat', 'backgroundRepeatX', 'backgroundRepeatY', 'borderBottomColor', 'borderBottomStyle', 'borderCollapse', 'borderColor', 'borderImage', 'borderImageRepeat', 'borderImageSlice', 'borderImageSource', 'borderLeftColor', 'borderLeftStyle', 'borderRightColor', 'borderRightStyle', 'borderStyle', 'borderTopColor', 'borderTopStyle', 'boxShadow', 'boxSizing', 'breakAfter', 'breakBefore', 'breakInside', 'bufferedRendering', 'captionSide', 'clear', 'clip', 'clipPath', 'color', 'columnCount', 'columnFill', 'columnRuleColor', 'columnRuleStyle', 'columnSpan', 'columns', 'contain', 'content', 'counterIncrement', 'counterReset', 'cursor', 'd', 'direction', 'display', 'emptyCells', 'fill', 'fillOpacity', 'fillRule', 'filter', 'flexDirection', 'flexFlow', 'flexWrap', 'float', 'floodColor', 'floodOpacity', 'font', 'fontFamily', 'fontFeatureSettings', 'fontKerning', 'fontStretch', 'fontStyle', 'fontVariant', 'fontVariantCaps', 'fontVariantLigatures', 'fontVariantNumeric', 'fontWeight', 'hyphens', 'imageRendering', 'isolation', 'justifyContent', 'lightingColor', 'listStyle', 'listStyleImage', 'listStylePosition', 'listStyleType', 'marker', 'markerEnd', 'markerMid', 'markerStart', 'mask', 'maskType', 'maxZoom', 'minZoom', 'mixBlendMode', 'objectFit', 'offsetPath', 'offsetRotation', 'opacity', 'order', 'orientation', 'orphans', 'outline', 'outlineColor', 'outlineStyle', 'overflow', 'overflowWrap', 'overflowX', 'overflowY', 'page', 'pageBreakAfter', 'pageBreakBefore', 'pageBreakInside', 'paintOrder', 'perspectiveOrigin', 'pointerEvents', 'position', 'quotes', 'resize', 'shapeImageThreshold', 'shapeOutside', 'shapeRendering', 'speak', 'src', 'stopColor', 'stopOpacity', 'stroke', 'strokeLinecap', 'strokeLinejoin', 'strokeMiterlimit', 'strokeOpacity', 'tableLayout', 'textAlign', 'textAlignLast', 'textAnchor', 'textCombineUpright', 'textDecoration', 'textOrientation', 'textOverflow', 'textRendering', 'textShadow', 'textSizeAdjust', 'textTransform', 'touchAction', 'transform', 'transformStyle', 'transition', 'transitionDelay', 'transitionDuration', 'transitionProperty', 'transitionTimingFunction', 'unicodeBidi', 'unicodeRange', 'userSelect', 'userZoom', 'vectorEffect', 'visibility', 'vertical-align', 'verticalAlign', 'webkitAppearance', 'whiteSpace', 'willChange', 'wordBreak', 'wordWrap', 'writingMode', 'zIndex', 'zoom', 'flex-grow', 'flex-shrink', 'object-position', 'transform-origin', 'align-content', 'align-items', 'align-self', 'alignment-baseline', 'animation-delay', 'animation-direction', 'animation-duration', 'animation-fill-mode', 'animation-iteration-count', 'animation-name', 'animation-play-state', 'animation-timing-function', 'backface-visibility', 'background-attachment', 'background-blend-mode', 'background-clip', 'background-color', 'background-image', 'background-origin', 'background-position', 'background-repeat', 'background-repeat-x', 'background-repeat-y', 'border-bottom-color', 'border-bottom-style', 'border-collapse', 'border-color', 'border-image', 'border-image-repeat', 'border-image-slice', 'border-image-source', 'border-left-color', 'border-left-style', 'border-right-color', 'border-right-style', 'border-style', 'border-top-color', 'border-top-style', 'box-shadow', 'box-sizing', 'break-after', 'break-before', 'break-inside', 'buffered-rendering', 'caption-side', 'clip-path', 'clip-rule', 'color-interpolation', 'color-interpolation-filters', 'color-rendering', 'column-count', 'column-fill', 'column-rule-color', 'column-rule-style', 'column-span', 'counter-increment', 'counter-reset', 'dominant-baseline', 'empty-cells', 'fill-opacity', 'fill-rule', 'flex-direction', 'flex-flow', 'flex-wrap', 'flood-color', 'flood-opacity', 'font-family', 'font-feature-settings', 'font-kerning', 'font-stretch', 'font-style', 'font-variant', 'font-variant-caps', 'font-variant-ligatures', 'font-variant-numeric', 'font-weight', 'image-rendering', 'justify-content', 'lighting-color', 'list-style', 'list-style-image', 'list-style-position', 'list-style-type', 'marker-end', 'marker-mid', 'marker-start', 'mask-type', 'max-zoom', 'min-zoom', 'mix-blend-mode', 'object-fit', 'offset-path', 'offset-rotation', 'outline-color', 'outline-style', 'overflow-wrap', 'overflow-x', 'overflow-y', 'page-break-after', 'page-break-before', 'page-break-inside', 'paint-order', 'perspective-origin', 'pointer-events', 'shape-image-threshold', 'shape-outside', 'shape-rendering', 'stop-color', 'stop-opacity', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'table-layout', 'text-align', 'text-align-last', 'text-anchor', 'text-combine-upright', 'text-decoration', 'text-orientation', 'text-overflow', 'text-rendering', 'text-shadow', 'text-size-adjust', 'text-transform', 'touch-action', 'transform-style', 'transition-delay', 'transition-duration', 'transition-property', 'transition-timing-function', 'unicode-bidi', 'unicode-range', 'user-select', 'user-zoom', 'vector-effect', 'webkit-app-region', 'webkit-appearance', 'webkit-background-clip', 'webkit-background-origin', 'webkit-border-after', 'webkit-border-after-color', 'webkit-border-after-style', 'webkit-border-before', 'webkit-border-before-color', 'webkit-border-before-style', 'webkit-border-end', 'webkit-border-end-color', 'webkit-border-end-style', 'webkit-border-image', 'webkit-border-start', 'webkit-border-start-color', 'webkit-border-start-style', 'webkit-box-align', 'webkit-box-decoration-break', 'webkit-box-direction', 'webkit-box-flex', 'webkit-box-flex-group', 'webkit-box-lines', 'webkit-box-ordinal-group', 'webkit-box-orient', 'webkit-box-pack', 'webkit-box-reflect', 'webkit-column-break-after', 'webkit-column-break-before', 'webkit-column-break-inside', 'webkit-font-smoothing', 'webkit-highlight', 'webkit-hyphenate-character', 'webkit-line-break', 'webkit-line-clamp', 'webkit-locale', 'webkit-margin-after-collapse', 'webkit-margin-before-collapse', 'webkit-margin-bottom-collapse', 'webkit-margin-collapse', 'webkit-margin-top-collapse', 'webkit-mask', 'webkit-mask-box-image', 'webkit-mask-box-image-repeat', 'webkit-mask-box-image-slice', 'webkit-mask-box-image-source', 'webkit-mask-clip', 'webkit-mask-composite', 'webkit-mask-image', 'webkit-mask-origin', 'webkit-mask-repeat', 'webkit-mask-repeat-x', 'webkit-mask-repeat-y', 'webkit-print-color-adjust', 'webkit-rtl-ordering', 'webkit-ruby-position', 'webkit-tap-highlight-color', 'webkit-text-combine', 'webkit-text-decorations-in-effect', 'webkit-text-emphasis', 'webkit-text-emphasis-color', 'webkit-text-emphasis-position', 'webkit-text-emphasis-style', 'webkit-text-fill-color', 'webkit-text-orientation', 'webkit-text-security', 'webkit-text-stroke-color', 'webkit-user-drag', 'webkit-user-modify', 'webkit-writing-mode', 'white-space', 'will-change', 'word-break', 'word-wrap', 'writing-mode', 'z-index', 'zoom'];
var staticData = {
Atoms: {
block: 'div',
div: 'div',
header: 'header',
footer: 'footer',
aside: 'aside',
article: 'article',
main: 'main',
nav: 'nav',
navigation: 'nav',
span: 'span',
text: 'p',
p: 'p',
paragraphe: 'p',
'ulist-container': 'ul',
ulist: 'ul',
ul: 'ul',
'unordered-list': 'ul',
'olist-container': 'ol',
olist: 'ol',
ol: 'ol',
'ordered-list': 'ol',
'list-element': 'li',
li: 'li',
code: 'pre',
pre: 'pre',
input: 'input',
textarea: 'textarea',
form: 'form',
image: 'img',
img: 'img',
button: 'button',
iframe: 'iframe',
video: 'video',
canvas: 'canvas',
audio: 'audio'
},
regex: {
DOMEvent: new RegExp('^(click|mousedown|mouseup|mousemove|change|touchstart|touchmove|touchend|input|focus|dlclick|mouseenter|mouseleave|mouseover|mouseout|blur|search|submit|play|pause|canplay|progress)$'),
animatableProps: new RegExp('background-position-|background-size|background-color|translate|scale|rotate|skew|margin-|padding-|top|left|right|bottom|color|font-size|width|height|opacity|width|height', 'gi')
},
sets: {
pxProperties: pxPropertiesArray,
degProperties: ['rotate', 'rotate-x', 'rotate-y', 'rotate-z', 'rotate-x', 'rotate-y', 'rotate-z', 'skew', 'skewX', 'skewY', 'skewZ', 'skew-x', 'skew-y', 'skew-z'],
transformProperties: ['translate', 'translateX', 'translateY', 'translateZ', 'translateX', 'translate-x', 'translateY', 'translate-y', 'translate-z', 'scale', 'scaleX', 'scaleY', 'scaleZ', 'scale-x', 'scale-y', 'scale-z', 'rotate', 'rotateX', 'rotateY', 'rotateZ', 'rotate-x', 'rotate-y', 'rotate-z', 'skew', 'skewX', 'skewY', 'skewZ', 'skew-x', 'skew-y', 'skew-z'],
styleProperties: stylePropertiesArray
}
};
/* eslint-disable */
var Atoms = function Atoms() {
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'block';
var types = staticData.Atoms;
return types[type];
};
var checkIfObject = function checkIfObject(toCheck, tryStatement, errorMessage) {
var error = function error() {
throw new Error(errorMessage);
};
try {
tryStatement();
} catch (err) {
error();
} finally {
if (!toCheck || toCheck === null || typeof toCheck === 'string' || typeof toCheck === 'number' || toCheck instanceof Array) {
error();
}
}
};
var parseBoolean = function parseBoolean(string) {
if (typeof string === 'undefined' || string === '') {
return true;
}
if (string === 'false' || Boolean(string) === false) {
return false;
}
return Boolean(string);
};
var checkEvent = function checkEvent(evt) {
return staticData.regex.DOMEvent.test(evt);
};
var closestSuperior = function closestSuperior(num, arr) {
var sortedArr = arr.sort(function (a, b) {
return a - b;
});
for (var i = 0; i < sortedArr.length; i++) {
if (parseFloat(num) < parseFloat(sortedArr[i])) {
return sortedArr[i];
}
}
return sortedArr[sortedArr.length - 1];
};
var pxProperties = new Set(staticData.sets.pxProperties);
var degProperties = new Set(staticData.sets.degProperties);
var transformProperties = new Set(staticData.sets.transformProperties);
var styleProperties = new Set(staticData.sets.styleProperties);
var isAnimatableProp = function isAnimatableProp(prop) {
return staticData.regex.animatableProps.test(prop);
};
var getNumFromString = function getNumFromString(str) {
if (typeof str === 'string') {
var num = str.match(/-(?=\d)|\d+|\.\d+/g);
return num !== null ? parseFloat(num.join('')) : 0;
}
return typeof parseFloat(str) === 'number' && !isNaN(parseFloat(str)) ? parseFloat(str) : 0;
};
var getUnitFromString = function getUnitFromString(str) {
var unit = '';
if (typeof str === 'string') {
var u = str.match ? str.match(/%|px|vh|vw|em|deg/g) : null;
unit = u !== null ? u[0] : '';
}
return unit;
};
var toDashed = function toDashed(str) {
return str.replace(/([A-Z])/g, function ($1) {
return '-' + $1.toLowerCase();
});
};
var prefixFor = function prefixFor(property) {
var propArray = property.split('-');
var ref = ['Webkit', 'Moz', 'ms'];
var i = void 0;
var j = void 0;
var k = void 0;
var len = void 0;
var len1 = void 0;
var prefix = void 0;
var prop = void 0;
var propertyName = void 0;
if (document.body.style[property] !== undefined) {
return '';
}
propertyName = '';
for (i = 0, len = propArray.length; i < len; i++) {
prop = propArray[i];
propertyName += prop.substring(0, 1).toUpperCase() + prop.substring(1);
}
for (j = 0, len1 = ref.length; j < len1; j++) {
prefix = ref[j];
k = prefix + propertyName;
if (document.body.style[k] !== undefined) {
return prefix;
}
}
return '';
};
var propertyWithPrefix = function propertyWithPrefix(property) {
var prefix = prefixFor(property);
if (prefix === 'Moz') {
return '' + prefix + (property.substring(0, 1).toUpperCase() + property.substring(1));
}
if (prefix !== '') {
return '-' + prefix.toLowerCase() + '-' + toDashed(property);
}
return toDashed(property);
};
var unitForProperty = function unitForProperty(k, v) {
if (pxProperties.contains(k)) {
var unit = getUnitFromString(v);
return unit !== '' ? unit : 'px';
} else if (degProperties.contains(k)) {
return 'deg';
} else if (transformProperties.contains(k)) {
return '';
} else if (styleProperties.contains(k)) {
return '';
}
return '';
};
var getMaxOfArray = function getMaxOfArray(numArray) {
/* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max */
if (numArray instanceof Array) {
var result = void 0;
var arrayOfNumber = numArray.filter(function (el) {
return !isNaN(parseFloat(el));
});
if (arrayOfNumber.length > 0) {
result = Math.max.apply(null, arrayOfNumber);
}
result = isNaN(result) ? 0 : result;
return result;
}
throw new Error('getMaxOfArray only works on an array');
};
var transformValueForProperty = function transformValueForProperty(k, v) {
if (!transformProperties.contains(k)) {
throw new Error(k + ' is not a transform property');
}
var value = 0;
var unit = void 0;
value = typeof v === 'string' && v.indexOf(',') >= 0 ? v.split(',') : getNumFromString(v);
unit = unitForProperty(k, v);
if (k.indexOf('scale') >= 0) {
unit = '';
} else if (degProperties.contains(k)) {
unit = 'deg';
}
var string = k + '(' + value + unit + ')';
if (value instanceof Array) {
value = value.map(function (val) {
return getNumFromString(val);
});
var res = '';
value.forEach(function (val, index) {
res += index > 0 ? ', ' + val + unit : '' + val + unit;
});
string = k + '(' + res + ')';
}
return { string: string, unit: unit, value: value };
};
var generateUUID = function generateUUID() {
var d = new Date().getTime();
if (window.performance && typeof window.performance.now === 'function') {
d += performance.now(); // use high-precision timer if available
}
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d / 16);
return (c === 'x' ? r : r & 0x3 | 0x8).toString(16);
});
return uuid;
};
var cutHex = function cutHex(h) {
return h.charAt(0) === '#' ? h.substring(1, 7) : h;
};
var hexToR = function hexToR(h) {
return parseInt(cutHex(h).substring(0, 2), 16);
};
var hexToG = function hexToG(h) {
return parseInt(cutHex(h).substring(2, 4), 16);
};
var hexToB = function hexToB(h) {
return parseInt(cutHex(h).substring(4, 6), 16);
};
var transformToColor = function transformToColor(propertie) {
var colorObj = void 0;
if (propertie[0] === '#') {
colorObj = {
r: hexToR(propertie),
g: hexToG(propertie),
b: hexToB(propertie),
a: 1
};
} else {
var par = typeof propertie === 'string' ? propertie.indexOf('(') : -1;
if (par >= 0) {
propertie = propertie.slice(par + 1, propertie.length - 1);
}
var rgba = typeof propertie === 'string' ? propertie.split(',') : [0, 0, 0, 0];
colorObj = {
r: parseInt(rgba[0], 10),
g: parseInt(rgba[1], 10),
b: parseInt(rgba[2], 10),
a: parseFloat(rgba[3] || 1)
};
}
return colorObj;
};
/* eslint-disable */
var linearEase = function linearEase(currentIteration, startValue, changeInValue, totalIterations) {
return changeInValue * currentIteration / totalIterations + startValue;
};
var easeInQuad = function easeInQuad(t, b, c, d) {
return c * (t /= d) * t + b;
};
var easeOutQuad = function easeOutQuad(t, b, c, d) {
return -c * (t /= d) * (t - 2) + b;
};
var easeInOutQuad = function easeInOutQuad(t, b, c, d) {
if ((t /= d / 2) < 1) return c / 2 * t * t + b;
return -c / 2 * (--t * (t - 2) - 1) + b;
};
var easeInCubic = function easeInCubic(t, b, c, d) {
return c * (t /= d) * t * t + b;
};
var easeOutCubic = function easeOutCubic(t, b, c, d) {
return c * ((t = t / d - 1) * t * t + 1) + b;
};
var easeInOutCubic = function easeInOutCubic(t, b, c, d) {
if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
return c / 2 * ((t -= 2) * t * t + 2) + b;
};
var easeInQuart = function easeInQuart(t, b, c, d) {
return c * (t /= d) * t * t * t + b;
};
var easeOutQuart = function easeOutQuart(t, b, c, d) {
return -c * ((t = t / d - 1) * t * t * t - 1) + b;
};
var easeInOutQuart = function easeInOutQuart(t, b, c, d) {
if ((t /= d / 2) < 1) return c / 2 * t * t * t * t + b;
return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
};
var easeInQuint = function easeInQuint(t, b, c, d) {
return c * (t /= d) * t * t * t * t + b;
};
var easeOutQuint = function easeOutQuint(t, b, c, d) {
return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
};
var easeInOutQuint = function easeInOutQuint(t, b, c, d) {
if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b;
return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
};
var easeInSine = function easeInSine(t, b, c, d) {
return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
};
var easeOutSine = function easeOutSine(t, b, c, d) {
return c * Math.sin(t / d * (Math.PI / 2)) + b;
};
var easeInOutSine = function easeInOutSine(t, b, c, d) {
return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
};
var easeInExpo = function easeInExpo(t, b, c, d) {
return t == 0 ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;
};
var easeOutExpo = function easeOutExpo(t, b, c, d) {
return t == d ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
};
var easeInOutExpo = function easeInOutExpo(t, b, c, d) {
if (t == 0) return b;
if (t == d) return b + c;
if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
};
var easeInCirc = function easeInCirc(t, b, c, d) {
return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
};
var easeOutCirc = function easeOutCirc(t, b, c, d) {
return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
};
var easeInOutCirc = function easeInOutCirc(t, b, c, d) {
if ((t /= d / 2) < 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
};
var easeInElastic = function easeInElastic(t, b, c, d) {
var s = 1.70158;var p = 0;var a = c;
if (t == 0) return b;if ((t /= d) == 1) return b + c;if (!p) p = d * 0.3;
if (a < Math.abs(c)) {
a = c;var s = p / 4;
} else var s = p / (2 * Math.PI) * Math.asin(c / a);
return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
};
var easeOutElastic = function easeOutElastic(t, b, c, d) {
var s = 1.70158;var p = 0;var a = c;
if (t == 0) return b;if ((t /= d) == 1) return b + c;if (!p) p = d * 0.3;
if (a < Math.abs(c)) {
a = c;var s = p / 4;
} else var s = p / (2 * Math.PI) * Math.asin(c / a);
return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
};
var easeInOutElastic = function easeInOutElastic(t, b, c, d) {
var s = 1.70158;var p = 0;var a = c;
if (t == 0) return b;if ((t /= d / 2) == 2) return b + c;if (!p) p = d * (0.3 * 1.5);
if (a < Math.abs(c)) {
a = c;var s = p / 4;
} else var s = p / (2 * Math.PI) * Math.asin(c / a);
if (t < 1) return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * 0.5 + c + b;
};
var easeInBack = function easeInBack(t, b, c, d, s) {
if (s == undefined) s = 1.70158;
return c * (t /= d) * t * ((s + 1) * t - s) + b;
};
var easeOutBack = function easeOutBack(t, b, c, d, s) {
if (s == undefined) s = 1.70158;
return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
};
var easeInOutBack = function easeInOutBack(t, b, c, d, s) {
if (s == undefined) s = 1.70158;
if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= 1.525) + 1) * t - s)) + b;
return c / 2 * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2) + b;
};
var easeInBounce = function easeInBounce(t, b, c, d) {
return c - easeOutBounce(d - t, 0, c, d) + b;
};
var easeOutBounce = function easeOutBounce(t, b, c, d) {
if ((t /= d) < 1 / 2.75) {
return c * (7.5625 * t * t) + b;
} else if (t < 2 / 2.75) {
return c * (7.5625 * (t -= 1.5 / 2.75) * t + 0.75) + b;
} else if (t < 2.5 / 2.75) {
return c * (7.5625 * (t -= 2.25 / 2.75) * t + 0.9375) + b;
}
return c * (7.5625 * (t -= 2.625 / 2.75) * t + 0.984375) + b;
};
var easeInOutBounce = function easeInOutBounce(t, b, c, d) {
if (t < d / 2) return easeInBounce(t * 2, 0, c, d) * 0.5 + b;
return easeOutBounce(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;
};
var Easings = /*#__PURE__*/Object.freeze({
linearEase: linearEase,
easeInQuad: easeInQuad,
easeOutQuad: easeOutQuad,
easeInOutQuad: easeInOutQuad,
easeInCubic: easeInCubic,
easeOutCubic: easeOutCubic,
easeInOutCubic: easeInOutCubic,
easeInQuart: easeInQuart,
easeOutQuart: easeOutQuart,
easeInOutQuart: easeInOutQuart,
easeInQuint: easeInQuint,
easeOutQuint: easeOutQuint,
easeInOutQuint: easeInOutQuint,
easeInSine: easeInSine,
easeOutSine: easeOutSine,
easeInOutSine: easeInOutSine,
easeInExpo: easeInExpo,
easeOutExpo: easeOutExpo,
easeInOutExpo: easeInOutExpo,
easeInCirc: easeInCirc,
easeOutCirc: easeOutCirc,
easeInOutCirc: easeInOutCirc,
easeInElastic: easeInElastic,
easeOutElastic: easeOutElastic,
easeInOutElastic: easeInOutElastic,
easeInBack: easeInBack,
easeOutBack: easeOutBack,
easeInOutBack: easeInOutBack,
easeInBounce: easeInBounce,
easeOutBounce: easeOutBounce,
easeInOutBounce: easeInOutBounce
});
/* eslint-disable */
var EventManager = function EventManager() {
this.listeners = {};
};
// place properties here
// Constructor
EventManager.prototype = {
// public methods
addListener: function addListener(event, fn) {
if (this.listeners[event]) {
if (fn instanceof Function) {
if (this.listeners[event].indexOf(fn) < 0) {
this.listeners[event].push(fn);
}
}
} else {
this.listeners[event] = [];
this.addListener(event, fn);
}
return this;
},
dispatchEvent: function dispatchEvent(event, params, context) {
params = params || {};
if (this.listeners[event]) {
if (context) {
this.listeners[event].forEach(function (f, index) {
f.call(context, params);
});
} else {
this.listeners[event].forEach(function (f, index) {
f.call(window, params);
});
}
}
return this;
},
removeListener: function removeListener(event, fn) {
if (this.listeners[event]) {
var fnIndex = this.listeners[event].indexOf(fn);
if (fnIndex > 0) {
this.listeners[event].splice(fnIndex, 1);
}
}
return this;
}
};
var eventManager = new EventManager();
/* eslint-disable */
/*!
* $script.js JS loader & dependency manager
* https://github.com/ded/script.js
* (c) Dustin Diaz 2014 | License MIT
*/
var doc = document,
head = doc.getElementsByTagName('head')[0],
f = false,
push = 'push',
readyState = 'readyState',
onreadystatechange = 'onreadystatechange',
list = {},
delay = {},
scripts = {},
scriptpath = void 0,
urlArgs = void 0;
function every(ar, fn) {
for (var i = 0, j = ar.length; i < j; ++i) {
if (!fn(ar[i])) return f;
}return 1;
}
function each(ar, fn) {
every(ar, function (el) {
fn(el);
return 1;
});
}
var $script = function $script(paths, idOrDone, optDone) {
paths = paths[push] ? paths : [paths];
var idOrDoneIsDone = idOrDone && idOrDone.call,
done = idOrDoneIsDone ? idOrDone : optDone,
id = idOrDoneIsDone ? paths.join('') : idOrDone,
queue = paths.length;
function loopFn(item) {
return item.call ? item() : list[item];
}
function callback() {
if (! --queue) {
list[id] = 1;
done && done();
for (var dset in delay) {
every(dset.split('|'), loopFn) && !each(delay[dset], loopFn) && (delay[dset] = []);
}
}
}
setTimeout(function () {
each(paths, function loading(path, force) {
if (path === null) return callback();
if (!force && !/^https?:\/\//.test(path) && scriptpath) {
path = path.indexOf('.js') === -1 ? scriptpath + path + '.js' : scriptpath + path;
}
if (scripts[path]) {
return scripts[path] == 2 ? callback() : setTimeout(function () {
loading(path, true);
}, 0);
}
scripts[path] = 1;
create(path, callback);
});
}, 0);
return $script;
};
function create(path, fn) {
var el = doc.createElement('script'),
loaded = void 0;
el.onload = el.onerror = el[onreadystatechange] = function () {
if (el[readyState] && !/^c|loade/.test(el[readyState]) || loaded) return;
el.onload = el[onreadystatechange] = null;
loaded = 1;
scripts[path] = 2;
fn();
};
el.async = 1;
el.src = urlArgs ? path + (path.indexOf('?') === -1 ? '?' : '&') + urlArgs : path;
head.insertBefore(el, head.lastChild);
}
$script.get = create;
$script.order = function (scripts, id, done) {
(function callback(s) {
s = scripts.shift();
!scripts.length ? $script(s, id, done) : $script(s, callback);
})();
};
$script.path = function (p) {
scriptpath = p;
};
$script.urlArgs = function (str) {
urlArgs = str;
};
$script.ready = function (deps, ready, req) {
deps = deps[push] ? deps : [deps];
var missing = [];
!each(deps, function (dep) {
list[dep] || missing[push](dep);
}) && every(deps, function (dep) {
return list[dep];
}) ? ready() : !function (key) {
delay[key] = delay[key] || [];
delay[key][push](ready);
req && req(missing);
}(deps.join('|'));
return $script;
};
$script.done = function (idOrDone) {
$script([null], idOrDone);
};
var conf = {
namespace: '_s4mConfig',
container: 'scene',
defaultAttributes: {
video: {
src: '',
type: 'video/mp4',
controls: 'true',
muted: 'true',
preload: 'true',
playsinline: 'true'
},
img: {
src: ''
},
iframe: {
src: ''
},
form: {
name: ''
},
input: {
name: ''
},
audio: {
src: ''
}
}
};
/*
Copyright 2016 Ciro André DE CARO
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/* eslint-disable */
var cycleParams = function cycleParams(queries, element, index, results) {
if ((typeof queries === 'undefined' ? 'undefined' : _typeof(queries)) === 'object') {
var found = true;
for (var key in queries) {
if (!element[key] || queries[key] !== element[key]) {
found = false;
continue;
}
}
if (found) {
results.push(index);
}
} else if (queries === element) {
results.push(index);
}
return results;
};
var findIndex = function findIndex(array, params, one) {
if (!(array instanceof Array)) throw new Error('findBy: can find only in array');
var length = array.length;
var results = [];
var index = 0;
while (index < length) {
if ((typeof params === 'undefined' ? 'undefined' : _typeof(params)) === _typeof(array[index])) {
cycleParams(params, array[index], index, results);
}
if (one && results.length > 0) {
return results[0];
}
index += 1;
}
return results;
};
raf();
/**
* Represents a MultimediaObject
* @class MultimediaObject
* @param {object | string} type - a JSON representing the object or the DOM type of the MultimediaObject
* @param {string} name - the name of the MultimediaObject
* @param {object} data - an object representing the datas which can be internally used by the MultimediaObject
* @param {object} style - an object representing the CSS style of the MultimediaObject, applied at creation
* @param {object} attributes - an object representing the DOM attributes of the MultimediaObject, applied at creation to the DOM Element
* @param {object} events - an object representing the Events provided by the object. Supporting only DOM events for the moment.
* @param {object} animations - a second separated Object representing the MultimediaObject state over time. Each step contain an object with style values wich will be precompiled and applied over time.
* @example
* <caption>Instanciation</caption>
* new MultimediaObject({
* type: 'div',
* style: {
* position: 'absolute',
* translateX: '10%'
* },
* attributes: {
* id: 'multimediaObject',
* 'data-test': 'test',
* },
* events: {
* click: function(event) {
* console.log(this);
* console.log(event);
* };
* }
* });
*/
var unserializeFunction = function unserializeFunction(serialized) {
var args = serialized.args.map(function (el) {
return el.replace(/\n+|(\/\*\*\/\n)+/g, '').replace(/^(\n+|\t+|\t\n+)(?!\w)$/gm, '').replace(/`/gm, '');
}),
body = serialized.body;
var fn = new Function();
try {
fn = new Function(args, body);
} catch (e) {
console.error(e);
}
return fn;
};
var MultimediaObject = function () {
function MultimediaObject() {
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'block';
var _this = this;
var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'multimediaObject';
var fps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 60;
classCallCheck(this, MultimediaObject);
this.uuid = generateUUID();
this.data = {};
this._style = {};
this.style = {};
this.attributes = {};
this.events = {};
this._events = {};
this.functions = {};
this.selectedAnimation = 'default';
this.currentAnimation = {};
this.animations = {};
this.breakpoints = [];
this.animated = false;
this.computedAnimations = [];
this.childs = [];
this.dependencies = [];
this.animatedProps = {};
this.innerHTML = '';
this.DOMParent = null;
this.DOMParentUUID = null;
this.reverse = false;
this.repeat = 0;
if ((typeof type === 'undefined' ? 'undefined' : _typeof(type)) === 'object') {
this.uuid = type.uuid || this.uuid;
this.name = name || type.name;
this.type = type.type || 'block';
this.load = true;
this.loadFromJSON(type);
this.applyFunctions();
this.addDefaultParameters();
this.init();
this.applyAttributes();
this.applyStyle();
this.applyEvents();
this.applyBreakpoints();
this.applyDependencies();
this.changeAnimation(this.selectedAnimation);
} else {
this.name = name;
this.type = type;
this.init();
this.addDefaultParameters();
}
this.fps = fps;
this.then = performance.now() || Date.now();
this.interval = 1000 / this.fps;
this.totalIteration = 0;
this.counter = 0;
this.animationStarted = false;
this.repeatCounter = 0;
if (!window.MultimediaObjectEditor) {
if (this.data.forceStart) {
this.startAnimation();
} else if (this.data.autostart && !(this.DOMParent instanceof MultimediaObject)) {
this.addListener('startAfterPreload', function () {
_this.startAnimation();
});
}
}
}
/**
* Inititalize the MultimediaObject
* generates the DOMElement, applyAttributes, sorts animations steps
*/
createClass(MultimediaObject, [{
key: 'init',
value: function init() {
this.generate(Atoms(this.type));
this.element.innerHTML = this.innerHTML;
this.getSortedSteps();
if (!window.MultimediaObjectEditor) {
if (!(this.DOMParent instanceof MultimediaObject)) {
if (window[conf.namespace]) {
this.appendElementTo(document.getElementById(window[conf.namespace].containerId));
} else {
this.appendElementTo();
}
}
}
this.applyAttributes({
id: /multimediaObject(\d+)?/.test(this.name) ? this.uuid : this.name
});
this.addGlobalStyle();
}
/**
* Add the default parameters set in the config file based on the type
*/
}, {
key: 'addDefaultParameters',
value: function addDefaultParameters() {
if (conf.defaultAttributes[this.type] && !this.load) {
for (var key in conf.defaultAttributes[this.type]) {
if (!this.attributes[key]) {
this.attributes[key] = conf.defaultAttributes[this.type][key];
}
}
}
this.data.autostart = typeof this.data.autostart === 'undefined' ? true : parseBoolean(this.data.autostart);
this.data.forceStart = typeof this.data.forceStart === 'undefined' ? false : parseBoolean(this.data.forceStart);
if (this.element) {
this.applyAttributes();
}
}
/**
* Check dependencies and perform action on the array
* @param {string} dependency - the dependency
* @param {string} pushOrSplice - push or splice
*/
}, {
key: 'checkDep',
value: function checkDep(dependency) {
var pushOrSplice = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'push';
var depIndex = this.dependencies.indexOf(dependency);
switch (pushOrSplice) {
case 'splice':
if (depIndex >= 0) {
this.dependencies.splice(depIndex, 1);
}
break;
case 'push':
default:
if (depIndex < 0) {
this.dependencies.push(dependency);
}
}
}
/**
* Require dependencies and add it to a dependencie bundle
* @param {object} dependencies - the dependencies to fetch
* @return {object} MultimediaObject
*/
}, {
key: 'applyDependencies',
value: function applyDependencies() {
var _this2 = this;
var dependencies = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.dependencies;
if (dependencies instanceof Array) {
dependencies.forEach(function (dep) {
_this2.checkDep(dep);
});
} else {
this.checkDep(dependencies);
}
return this;
}
/**
* Remove dependencies from the dependencies array if it exists
* @param {array | string} dependencies - the array of dependencies to delete
*/
}, {
key: 'removeDependencies',
value: function removeDependencies() {
var _this3 = this;
var dependencies = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.dependencies;
if (dependencies instanceof Array) {
dependencies.forEach(function (dep) {
_this3.checkDep(dep, 'splice');
});
} else {
this.checkDep(dependencies, 'splice');
}
return this;
}
/**
* Require the dependencies and make them available in a certain context
* @param {function} callback - the callback with the contexts
*/
}, {
key: 'requireDependencies',
value: function requireDependencies(callback) {
if (this.dependencies.length > 0) {
$script(this.dependencies, 'dependencies');
$script.ready('dependencies', callback);
} else {
callback();
}
}
/**
* Add a global style object to the page
* @param {object} style - the CSS style properties to apply
* @param {function} callback - the callback to execute
* @return {object} MultimediaObject
*/
}, {
key: 'addGlobalStyle',
value: function addGlobalStyle() {
var style = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.data.globalStyle;
var callback = arguments[1];
if (!style) {
return this;
}
if (typeof style !== 'string') {
throw new Error('addGlobalStyle: style is not a string');
}
var existingStyle = document.getElementById(this.uuid + '-style');
if (existingStyle !== null) {
document.head.removeChild(existingStyle);
}
var styleMarkup = document.createElement('style');
var styleText = style;
styleMarkup.innerHTML = styleText;
styleMarkup.id = this.uuid + '-style';
styleMarkup.type = 'text/css';
document.head.appendChild(styleMarkup);
if (callback) {
window.setTimeout(callback, 100);
}
return this;
}
/**
* Apply the object in parameter as style properties
* @param {object} properties - the CSS style properties to apply
* @return {object} MultimediaObject
*/
}, {
key: 'applyStyle',
value: function applyStyle() {
var properties = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.style;
var override = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
checkIfObject(properties, function () {
return Object.keys(properties);
}, 'style must be an object');
var k = void 0;
var transforms = [];
var v = void 0;
var _style = Object.keys(this._style).length;
for (k in properties) {
v = properties[k];
if (transformProperties.contains(k)) {
transforms.push([k, v]);
var val = transformValueForProperty(k, v);
var treatedVal = '' + val.value + val.unit;
if (_style < 1 || override) {
this._style[k] = treatedVal;
}
this.style[k] = treatedVal;
} else if (pxProperties.contains(k)) {
var _val = '' + getNumFromString(v) + unitForProperty(k, v);
if (_style < 1 || override) {
this._style[k] = _val;
}
this.style[k] = _val;
this.element.style[k] = _val;
} else if (styleProperties.contains(k)) {
if (_style < 1 || override) {
this._style[k] = v;
}
this.style[k] = v;
if (typeof v === 'string' && v.indexOf('{{absoluteAssetURL}}') >= 0 && window[conf.namespace]) {
v = v.replace('{{absoluteAssetURL}}', window.MultimediaObjectEditor ? this.data.absoluteAssetURL : window[conf.namespace].absoluteAssetURL);
}
this.element.style[k] = v;
} else {
var _val2 = '' + v + unitForProperty(k, v);
// console.log(v);
if (Object.keys(this.events).indexOf(k) < 0) {
this.style[propertyWithPrefix(k)] = _val2;
if (_style < 1 || override) {
this._style[propertyWithPrefix(k)] = _val2;
}
if (typeof v === 'string' && v.indexOf('{{absoluteAssetURL}}') >= 0 && window[conf.namespace]) {
v = v.replace('{{absoluteAssetURL}}', window.MultimediaObjectEditor ? this.data.absoluteAssetURL : window[conf.namespace].absoluteAssetURL);
}
this.element.style[propertyWithPrefix(k)] = v;
}
}
}
var z = [0, 1, 2, 3];
var trans = {
x: this._style.translateX ? getNumFromString(this._style.translateX) : 0,
y: this._style.translateY ? getNumFromString(this._style.translateY) : 0,
z: this._style.translateZ ? getNumFromString(this._style.translateZ) : 0,
xU: this._style.translateX ? getUnitFromString(this._style.translateX) : 'px',
yU: this._style.translateY ? getUnitFromString(this._style.translateY) : 'px',
zU: this._style.translateZ ? getUnitFromString(this._style.translateZ) : 'px'
};
var rot = {
x: this._style.rotateX ? getNumFromString(this._style.rotateX) : 0,
y: this._style.rotateY ? getNumFromString(this._style.rotateY) : 0,
z: this._style.rotateZ ? getNumFromString(this._style.rotateZ) || getNumFromString(this._style.rotate) : 0,
u: 'deg'
};
var ske = {
x: this._style.skewX ? getNumFromString(this._style.skewX) : 0,
y: this._style.skewY ? getNumFromString(this._style.skewY) : 0,
u: 'deg'
};
var sca = {
x: this._style.scaleX ? getNumFromString(this._style.scaleX) : 1,
y: this._style.scaleY ? getNumFromString(this._style.scaleY) : 1
};
if (transforms.length > 0) {
v = transforms.map(function (transform) {
return transformValueForProperty(transform[0], transform[1]).string;
});
v.forEach(function (a) {
if (a.indexOf('translateX') >= 0 || a.indexOf('translate-x') >= 0) {
trans.x = getNumFromString(a);
trans.xU = getUnitFromString(a);
} else if (a.indexOf('translateY') >= 0 || a.indexOf('translate-y') >= 0) {
trans.y = getNumFromString(a);
trans.yU = getUnitFromString(a);
} else if (a.indexOf('translateZ') >= 0 || a.indexOf('translate-z') >= 0) {
trans.z = getNumFromString(a);
trans.zU = getUnitFromString(a);
}
if (a.indexOf('rotateX') >= 0 || a.indexOf('rotate-x') >= 0) {
rot.x = getNumFromString(a);
} else if (a.indexOf('rotateY') >= 0 || a.indexOf('rotate-y') >= 0) {
rot.y = getNumFromString(a);
} else if (a.indexOf('rotateZ') >= 0 || a.indexOf('rotate-z') >= 0) {
rot.z = getNumFromString(a);
} else if (a.indexOf('rotate') >= 0) {
rot.z = getNumFromString(a);
}
if (a.indexOf('scaleX') >= 0 || a.indexOf('scale-x') >= 0) {
sca.