Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- Object.defineProperty(exports, '__esModule', { value: true });
- var core = require('@react-spring/core');
- var reactDom = require('react-dom');
- var shared = require('@react-spring/shared');
- var animated$1 = require('@react-spring/animated');
- function _objectWithoutPropertiesLoose(source, excluded) {
- if (source == null) return {};
- var target = {};
- var sourceKeys = Object.keys(source);
- var key, i;
- for (i = 0; i < sourceKeys.length; i++) {
- key = sourceKeys[i];
- if (excluded.indexOf(key) >= 0) continue;
- target[key] = source[key];
- }
- return target;
- }
- const _excluded$2 = ["style", "children", "scrollTop", "scrollLeft"];
- const isCustomPropRE = /^--/;
- function dangerousStyleValue(name, value) {
- console.log("name in dSV", name);
- console.log("value in dSV", value);
- if (value == null || typeof value === 'boolean' || value === '') return '';
- if (typeof value === 'number' && value !== 0 && !isCustomPropRE.test(name) && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) return value + 'px';
- return ('' + value).trim();
- }
- const attributeCache = {};
- function applyAnimatedValues(instance, props) {
- console.log("instance", instance)
- console.log("props", props)
- if (!instance.nodeType || !instance.setAttribute) {
- return false;
- }
- const isFilterElement = instance.nodeName === 'filter' || instance.parentNode && instance.parentNode.nodeName === 'filter';
- let attributes;
- let style;
- let children;
- let scrollTop;
- let scrollLeft;
- try {
- const _ref = props;
- style = _ref.style;
- children = _ref.children;
- scrollTop = _ref.scrollTop;
- scrollLeft = _ref.scrollLeft;
- attributes = _objectWithoutPropertiesLoose(_ref, _excluded$2);
- } catch (e) {
- console.log('you were right', props);
- throw e;
- }
- const values = Object.values(attributes);
- const names = Object.keys(attributes).map(name => isFilterElement || instance.hasAttribute(name) ? name : attributeCache[name] || (attributeCache[name] = name.replace(/([A-Z])/g, n => '-' + n.toLowerCase())));
- if (children !== void 0) {
- instance.textContent = children;
- }
- try {
- for (let name in style) {
- console.log("name", name)
- console.log("style", style)
- if (style.hasOwnProperty(name)) {
- console.log("style.hasOwnProperty(name)");
- const value = dangerousStyleValue(name, style[name]);
- console.log("value", value);
- if (name === 'float') {
- console.log('here');
- name = 'cssFloat';
- } else if (isCustomPropRE.test(name)) {
- console.log('here 2');
- instance.style.setProperty(name, value);
- } else {
- console.log('here 3');
- instance.style[name] = value;
- }
- }
- }
- } catch (e) {
- console.log('line 81');
- throw e;
- }
- try {
- names.forEach((name, i) => {
- instance.setAttribute(name, values[i]);
- });
- } catch (e) {
- console.log('line 85');
- throw e;
- }
- if (scrollTop !== void 0) {
- instance.scrollTop = scrollTop;
- }
- if (scrollLeft !== void 0) {
- instance.scrollLeft = scrollLeft;
- }
- }
- let isUnitlessNumber = {
- animationIterationCount: true,
- borderImageOutset: true,
- borderImageSlice: true,
- borderImageWidth: true,
- boxFlex: true,
- boxFlexGroup: true,
- boxOrdinalGroup: true,
- columnCount: true,
- columns: true,
- flex: true,
- flexGrow: true,
- flexPositive: true,
- flexShrink: true,
- flexNegative: true,
- flexOrder: true,
- gridRow: true,
- gridRowEnd: true,
- gridRowSpan: true,
- gridRowStart: true,
- gridColumn: true,
- gridColumnEnd: true,
- gridColumnSpan: true,
- gridColumnStart: true,
- fontWeight: true,
- lineClamp: true,
- lineHeight: true,
- opacity: true,
- order: true,
- orphans: true,
- tabSize: true,
- widows: true,
- zIndex: true,
- zoom: true,
- fillOpacity: true,
- floodOpacity: true,
- stopOpacity: true,
- strokeDasharray: true,
- strokeDashoffset: true,
- strokeMiterlimit: true,
- strokeOpacity: true,
- strokeWidth: true
- };
- const prefixKey = (prefix, key) => prefix + key.charAt(0).toUpperCase() + key.substring(1);
- const prefixes = ['Webkit', 'Ms', 'Moz', 'O'];
- isUnitlessNumber = Object.keys(isUnitlessNumber).reduce((acc, prop) => {
- prefixes.forEach(prefix => acc[prefixKey(prefix, prop)] = acc[prop]);
- return acc;
- }, isUnitlessNumber);
- const _excluded$1 = ["x", "y", "z"];
- const domTransforms = /^(matrix|translate|scale|rotate|skew)/;
- const pxTransforms = /^(translate)/;
- const degTransforms = /^(rotate|skew)/;
- const addUnit = (value, unit) => shared.is.num(value) && value !== 0 ? value + unit : value;
- const isValueIdentity = (value, id) => shared.is.arr(value) ? value.every(v => isValueIdentity(v, id)) : shared.is.num(value) ? value === id : parseFloat(value) === id;
- class AnimatedStyle extends animated$1.AnimatedObject {
- constructor(_ref) {
- let {
- x,
- y,
- z
- } = _ref,
- style = _objectWithoutPropertiesLoose(_ref, _excluded$1);
- const inputs = [];
- const transforms = [];
- if (x || y || z) {
- inputs.push([x || 0, y || 0, z || 0]);
- transforms.push(xyz => [`translate3d(${xyz.map(v => addUnit(v, 'px')).join(',')})`, isValueIdentity(xyz, 0)]);
- }
- shared.eachProp(style, (value, key) => {
- if (key === 'transform') {
- inputs.push([value || '']);
- transforms.push(transform => [transform, transform === '']);
- } else if (domTransforms.test(key)) {
- delete style[key];
- if (shared.is.und(value)) return;
- const unit = pxTransforms.test(key) ? 'px' : degTransforms.test(key) ? 'deg' : '';
- inputs.push(shared.toArray(value));
- transforms.push(key === 'rotate3d' ? ([x, y, z, deg]) => [`rotate3d(${x},${y},${z},${addUnit(deg, unit)})`, isValueIdentity(deg, 0)] : input => [`${key}(${input.map(v => addUnit(v, unit)).join(',')})`, isValueIdentity(input, key.startsWith('scale') ? 1 : 0)]);
- }
- });
- if (inputs.length) {
- style.transform = new FluidTransform(inputs, transforms);
- }
- super(style);
- }
- }
- class FluidTransform extends shared.FluidValue {
- constructor(inputs, transforms) {
- super();
- this._value = null;
- this.inputs = inputs;
- this.transforms = transforms;
- }
- get() {
- return this._value || (this._value = this._get());
- }
- _get() {
- let transform = '';
- let identity = true;
- shared.each(this.inputs, (input, i) => {
- const arg1 = shared.getFluidValue(input[0]);
- const [t, id] = this.transforms[i](shared.is.arr(arg1) ? arg1 : input.map(shared.getFluidValue));
- transform += ' ' + t;
- identity = identity && id;
- });
- return identity ? 'none' : transform;
- }
- observerAdded(count) {
- if (count == 1) shared.each(this.inputs, input => shared.each(input, value => shared.hasFluidValue(value) && shared.addFluidObserver(value, this)));
- }
- observerRemoved(count) {
- if (count == 0) shared.each(this.inputs, input => shared.each(input, value => shared.hasFluidValue(value) && shared.removeFluidObserver(value, this)));
- }
- eventObserved(event) {
- if (event.type == 'change') {
- this._value = null;
- }
- shared.callFluidObservers(this, event);
- }
- }
- const primitives = ['a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'cite', 'code', 'col', 'colgroup', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'menu', 'menuitem', 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr', 'circle', 'clipPath', 'defs', 'ellipse', 'foreignObject', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'svg', 'text', 'tspan'];
- const _excluded = ["scrollTop", "scrollLeft"];
- core.Globals.assign({
- batchedUpdates: reactDom.unstable_batchedUpdates,
- createStringInterpolator: shared.createStringInterpolator,
- colors: shared.colors
- });
- const host = animated$1.createHost(primitives, {
- applyAnimatedValues,
- createAnimatedStyle: style => new AnimatedStyle(style),
- getComponentProps: _ref => {
- let props = _objectWithoutPropertiesLoose(_ref, _excluded);
- return props;
- }
- });
- const animated = host.animated;
- exports.a = animated;
- exports.animated = animated;
- Object.keys(core).forEach(function (k) {
- if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
- enumerable: true,
- get: function () {
- return core[k];
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment