UNPKG

react-flip-toolkit

Version:

Configurable FLIP animation helpers for React

1,309 lines (1,190 loc) 115 kB
/*! * react-flip-toolkit v1.0.0 * MIT Licensed */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(require("react")); else if(typeof define === 'function' && define.amd) define(["react"], factory); else if(typeof exports === 'object') exports["ReactFlipToolkit"] = factory(require("react")); else root["ReactFlipToolkit"] = factory(root["React"]); })(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_7__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); /******/ } /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 15); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "currentTime", function() { return currentTime; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "onFrameStart", function() { return onFrameStart; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "onFrameUpdate", function() { return onFrameUpdate; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "onFrameRender", function() { return onFrameRender; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "onFrameEnd", function() { return onFrameEnd; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cancelOnFrameStart", function() { return cancelOnFrameStart; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cancelOnFrameUpdate", function() { return cancelOnFrameUpdate; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cancelOnFrameRender", function() { return cancelOnFrameRender; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cancelOnFrameEnd", function() { return cancelOnFrameEnd; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "timeSinceLastFrame", function() { return timeSinceLastFrame; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "currentFrameTime", function() { return currentFrameTime; }); var hasRAF = typeof window !== 'undefined' && window.requestAnimationFrame !== undefined; var prevTime = 0; var onNextFrame = hasRAF ? function (callback) { return window.requestAnimationFrame(callback); } : function (callback) { var currentTime = Date.now(); var timeToCall = Math.max(0, 16.7 - (currentTime - prevTime)); prevTime = currentTime + timeToCall; setTimeout(function () { return callback(prevTime); }, timeToCall); }; function createRenderStep(startRenderLoop) { var functionsToRun = []; var functionsToRunNextFrame = []; var numThisFrame = 0; var isProcessing = false; var i = 0; return { cancel: function (callback) { var indexOfCallback = functionsToRunNextFrame.indexOf(callback); if (indexOfCallback !== -1) { functionsToRunNextFrame.splice(indexOfCallback, 1); } }, process: function () { isProcessing = true; _a = [functionsToRunNextFrame, functionsToRun], functionsToRun = _a[0], functionsToRunNextFrame = _a[1]; functionsToRunNextFrame.length = 0; numThisFrame = functionsToRun.length; for (i = 0; i < numThisFrame; i++) { functionsToRun[i](); } isProcessing = false; var _a; }, schedule: function (callback, immediate) { if (immediate === void 0) { immediate = false; } startRenderLoop(); var addToCurrentBuffer = immediate && isProcessing; var buffer = addToCurrentBuffer ? functionsToRun : functionsToRunNextFrame; if (buffer.indexOf(callback) === -1) { buffer.push(callback); if (addToCurrentBuffer) { numThisFrame = functionsToRun.length; } } }, }; } var HAS_PERFORMANCE_NOW = typeof performance !== 'undefined' && performance.now !== undefined; var currentTime = HAS_PERFORMANCE_NOW ? function () { return performance.now(); } : function () { return Date.now(); }; var willRenderNextFrame = false; var MAX_ELAPSED = 40; var defaultElapsed = 16.7; var useDefaultElapsed = true; var currentFramestamp = 0; var elapsed = 0; function startRenderLoop() { if (willRenderNextFrame) return; willRenderNextFrame = true; useDefaultElapsed = true; onNextFrame(processFrame); } var frameStart = createRenderStep(startRenderLoop); var frameUpdate = createRenderStep(startRenderLoop); var frameRender = createRenderStep(startRenderLoop); var frameEnd = createRenderStep(startRenderLoop); function processFrame(framestamp) { willRenderNextFrame = false; elapsed = useDefaultElapsed ? defaultElapsed : Math.max(Math.min(framestamp - currentFramestamp, MAX_ELAPSED), 1); if (!useDefaultElapsed) defaultElapsed = elapsed; currentFramestamp = framestamp; frameStart.process(); frameUpdate.process(); frameRender.process(); frameEnd.process(); if (willRenderNextFrame) useDefaultElapsed = false; } var onFrameStart = frameStart.schedule; var onFrameUpdate = frameUpdate.schedule; var onFrameRender = frameRender.schedule; var onFrameEnd = frameEnd.schedule; var cancelOnFrameStart = frameStart.cancel; var cancelOnFrameUpdate = frameUpdate.cancel; var cancelOnFrameRender = frameRender.cancel; var cancelOnFrameEnd = frameEnd.cancel; var timeSinceLastFrame = function () { return elapsed; }; var currentFrameTime = function () { return currentFramestamp; }; /***/ }), /* 1 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __assign = (this && this.__assign) || Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]]; return t; }; Object.defineProperty(exports, "__esModule", { value: true }); var chainable_1 = __webpack_require__(22); var observer_1 = __webpack_require__(23); var Action = (function (_super) { __extends(Action, _super); function Action() { return _super !== null && _super.apply(this, arguments) || this; } Action.prototype.create = function (props) { return new Action(props); }; Action.prototype.start = function (observerCandidate) { if (observerCandidate === void 0) { observerCandidate = {}; } var isComplete = false; var subscription = { stop: function () { return undefined; } }; var _a = this.props, init = _a.init, observerProps = __rest(_a, ["init"]); var observer = observer_1.default(observerCandidate, observerProps, function () { isComplete = true; subscription.stop(); }); var api = init(observer); subscription = api ? __assign({}, subscription, api) : subscription; if (observerCandidate.registerParent) { observerCandidate.registerParent(subscription); } if (isComplete) subscription.stop(); return subscription; }; return Action; }(chainable_1.default)); exports.Action = Action; exports.default = (function (init) { return new Action({ init: init }); }); //# sourceMappingURL=index.js.map /***/ }), /* 2 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var DEFAULT_OVERSHOOT_STRENGTH = 1.525; exports.createReversedEasing = function (easing) { return function (p) { return 1 - easing(1 - p); }; }; exports.createMirroredEasing = function (easing) { return function (p) { return (p <= 0.5) ? easing(2 * p) / 2 : (2 - easing(2 * (1 - p))) / 2; }; }; exports.linear = function (p) { return p; }; exports.createExpoIn = function (power) { return function (p) { return Math.pow(p, power); }; }; exports.easeIn = exports.createExpoIn(2); exports.easeOut = exports.createReversedEasing(exports.easeIn); exports.easeInOut = exports.createMirroredEasing(exports.easeIn); exports.circIn = function (p) { return 1 - Math.sin(Math.acos(p)); }; exports.circOut = exports.createReversedEasing(exports.circIn); exports.circInOut = exports.createMirroredEasing(exports.circOut); exports.createBackIn = function (power) { return function (p) { return (p * p) * ((power + 1) * p - power); }; }; exports.backIn = exports.createBackIn(DEFAULT_OVERSHOOT_STRENGTH); exports.backOut = exports.createReversedEasing(exports.backIn); exports.backInOut = exports.createMirroredEasing(exports.backIn); exports.createAnticipateEasing = function (power) { var backEasing = exports.createBackIn(power); return function (p) { return ((p *= 2) < 1) ? 0.5 * backEasing(p) : 0.5 * (2 - Math.pow(2, -10 * (p - 1))); }; }; exports.anticipate = exports.createAnticipateEasing(DEFAULT_OVERSHOOT_STRENGTH); var NEWTON_ITERATIONS = 8; var NEWTON_MIN_SLOPE = 0.001; var SUBDIVISION_PRECISION = 0.0000001; var SUBDIVISION_MAX_ITERATIONS = 10; var K_SPLINE_TABLE_SIZE = 11; var K_SAMPLE_STEP_SIZE = 1.0 / (K_SPLINE_TABLE_SIZE - 1.0); var FLOAT_32_SUPPORTED = (typeof Float32Array !== 'undefined'); var a = function (a1, a2) { return 1.0 - 3.0 * a2 + 3.0 * a1; }; var b = function (a1, a2) { return 3.0 * a2 - 6.0 * a1; }; var c = function (a1) { return 3.0 * a1; }; var getSlope = function (t, a1, a2) { return 3.0 * a(a1, a2) * t * t + 2.0 * b(a1, a2) * t + c(a1); }; var calcBezier = function (t, a1, a2) { return ((a(a1, a2) * t + b(a1, a2)) * t + c(a1)) * t; }; function cubicBezier(mX1, mY1, mX2, mY2) { var sampleValues = FLOAT_32_SUPPORTED ? new Float32Array(K_SPLINE_TABLE_SIZE) : new Array(K_SPLINE_TABLE_SIZE); var _precomputed = false; var binarySubdivide = function (aX, aA, aB) { var i = 0; var currentX; var currentT; do { currentT = aA + (aB - aA) / 2.0; currentX = calcBezier(currentT, mX1, mX2) - aX; if (currentX > 0.0) { aB = currentT; } else { aA = currentT; } } while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS); return currentT; }; var newtonRaphsonIterate = function (aX, aGuessT) { var i = 0; var currentSlope = 0; var currentX; for (; i < NEWTON_ITERATIONS; ++i) { currentSlope = getSlope(aGuessT, mX1, mX2); if (currentSlope === 0.0) { return aGuessT; } currentX = calcBezier(aGuessT, mX1, mX2) - aX; aGuessT -= currentX / currentSlope; } return aGuessT; }; var calcSampleValues = function () { for (var i = 0; i < K_SPLINE_TABLE_SIZE; ++i) { sampleValues[i] = calcBezier(i * K_SAMPLE_STEP_SIZE, mX1, mX2); } }; var getTForX = function (aX) { var intervalStart = 0.0; var currentSample = 1; var lastSample = K_SPLINE_TABLE_SIZE - 1; var dist = 0.0; var guessForT = 0.0; var initialSlope = 0.0; for (; currentSample != lastSample && sampleValues[currentSample] <= aX; ++currentSample) { intervalStart += K_SAMPLE_STEP_SIZE; } --currentSample; dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]); guessForT = intervalStart + dist * K_SAMPLE_STEP_SIZE; initialSlope = getSlope(guessForT, mX1, mX2); if (initialSlope >= NEWTON_MIN_SLOPE) { return newtonRaphsonIterate(aX, guessForT); } else if (initialSlope === 0.0) { return guessForT; } else { return binarySubdivide(aX, intervalStart, intervalStart + K_SAMPLE_STEP_SIZE); } }; var precompute = function () { _precomputed = true; if (mX1 != mY1 || mX2 != mY2) { calcSampleValues(); } }; var resolver = function (aX) { var returnValue; if (!_precomputed) { precompute(); } if (mX1 === mY1 && mX2 === mY2) { returnValue = aX; } else if (aX === 0) { returnValue = 0; } else if (aX === 1) { returnValue = 1; } else { returnValue = calcBezier(getTForX(aX), mY1, mY2); } return returnValue; }; return resolver; } exports.cubicBezier = cubicBezier; ; //# sourceMappingURL=easing.js.map /***/ }), /* 3 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var __assign = (this && this.__assign) || Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; Object.defineProperty(exports, "__esModule", { value: true }); var framesync_1 = __webpack_require__(0); var style_value_types_1 = __webpack_require__(4); var calc_1 = __webpack_require__(5); var noop = function (v) { return v; }; exports.appendUnit = function (unit) { return function (v) { return "" + v + unit; }; }; exports.applyOffset = function (from, to) { var hasReceivedFrom = true; if (to === undefined) { to = from; hasReceivedFrom = false; } var getOffset = function (v) { return v - from; }; var applyOffsetTo = function (v) { return v + to; }; return function (v) { if (hasReceivedFrom) { return applyOffsetTo(getOffset(v)); } else { from = v; hasReceivedFrom = true; return to; } }; }; var blend = function (from, to, v) { var fromExpo = from * from; var toExpo = to * to; return Math.sqrt(v * (toExpo - fromExpo) + fromExpo); }; exports.blendColor = function (from, to) { var fromColor = (typeof from === 'string') ? style_value_types_1.color.parse(from) : from; var toColor = (typeof to === 'string') ? style_value_types_1.color.parse(to) : to; var blended = __assign({}, fromColor); var blendFunc = (from.hue !== undefined || typeof from === 'string' && style_value_types_1.hsla.test(from)) ? calc_1.getValueFromProgress : blend; return function (v) { blended = __assign({}, blended); for (var key in blended) { if (key !== 'alpha' && blended.hasOwnProperty(key)) { blended[key] = blendFunc(fromColor[key], toColor[key], v); } } blended.alpha = calc_1.getValueFromProgress(fromColor.alpha, toColor.alpha, v); return blended; }; }; exports.clamp = function (min, max) { return function (v) { return Math.min(Math.max(v, min), max); }; }; var combineFunctions = function (a, b) { return function (v) { return b(a(v)); }; }; exports.pipe = function () { var transformers = []; for (var _i = 0; _i < arguments.length; _i++) { transformers[_i] = arguments[_i]; } return transformers.reduce(combineFunctions); }; exports.conditional = function (check, apply) { return function (v) { return check(v) ? apply(v) : v; }; }; var slowInterpolate = function (input, output, rangeLength, rangeEasing) { var finalIndex = rangeLength - 1; if (input[0] > input[finalIndex]) { input.reverse(); output.reverse(); } return function (v) { if (v <= input[0]) { return output[0]; } if (v >= input[finalIndex]) { return output[finalIndex]; } var i = 1; for (; i < rangeLength; i++) { if (input[i] > v || i === finalIndex) { break; } } var progressInRange = calc_1.getProgressFromValue(input[i - 1], input[i], v); var easedProgress = (rangeEasing) ? rangeEasing[i - 1](progressInRange) : progressInRange; return calc_1.getValueFromProgress(output[i - 1], output[i], easedProgress); }; }; var fastInterpolate = function (minA, maxA, minB, maxB) { return function (v) { return (((v - minA) * (maxB - minB)) / (maxA - minA)) + minB; }; }; exports.interpolate = function (input, output, rangeEasing) { var rangeLength = input.length; return rangeLength !== 2 ? slowInterpolate(input, output, rangeLength, rangeEasing) : fastInterpolate(input[0], input[1], output[0], output[1]); }; exports.generateStaticSpring = function (alterDisplacement) { if (alterDisplacement === void 0) { alterDisplacement = noop; } return function (constant, origin) { return function (v) { var displacement = origin - v; var springModifiedDisplacement = -constant * (0 - alterDisplacement(Math.abs(displacement))); return (displacement <= 0) ? origin + springModifiedDisplacement : origin - springModifiedDisplacement; }; }; }; exports.linearSpring = exports.generateStaticSpring(); exports.nonlinearSpring = exports.generateStaticSpring(Math.sqrt); exports.wrap = function (min, max) { return function (v) { var rangeSize = max - min; return ((v - min) % rangeSize + rangeSize) % rangeSize + min; }; }; exports.smooth = function (strength) { if (strength === void 0) { strength = 50; } var previousValue = 0; var lastUpdated = 0; return function (v) { var currentFramestamp = framesync_1.currentFrameTime(); var timeDelta = (currentFramestamp !== lastUpdated) ? currentFramestamp - lastUpdated : 0; var newValue = timeDelta ? calc_1.smooth(v, previousValue, timeDelta, strength) : previousValue; lastUpdated = currentFramestamp; previousValue = newValue; return newValue; }; }; exports.snap = function (points) { if (typeof points === 'number') { return function (v) { return Math.round(v / points) * points; }; } else { var i_1 = 0; var numPoints_1 = points.length; return function (v) { var lastDistance = Math.abs(points[0] - v); for (i_1 = 1; i_1 < numPoints_1; i_1++) { var point = points[i_1]; var distance = Math.abs(point - v); if (distance === 0) return point; if (distance > lastDistance) return points[i_1 - 1]; if (i_1 === numPoints_1 - 1) return point; lastDistance = distance; } }; } }; exports.steps = function (st, min, max) { if (min === void 0) { min = 0; } if (max === void 0) { max = 1; } return function (v) { var progress = calc_1.getProgressFromValue(min, max, v); return calc_1.getValueFromProgress(min, max, calc_1.stepProgress(st, progress)); }; }; exports.transformMap = function (childTransformers) { return function (v) { var output = __assign({}, v); for (var key in childTransformers) { if (childTransformers.hasOwnProperty(key)) { var childTransformer = childTransformers[key]; output[key] = childTransformer(v[key]); } } return output; }; }; //# sourceMappingURL=transformers.js.map /***/ }), /* 4 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getValueFromFunctionString", function() { return getValueFromFunctionString; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "splitCommaDelimited", function() { return splitCommaDelimited; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "splitColorValues", function() { return splitColorValues; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "number", function() { return number; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "alpha", function() { return alpha; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "degrees", function() { return degrees; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "percent", function() { return percent; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "px", function() { return px; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scale", function() { return scale; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "complex", function() { return complex; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbUnit", function() { return rgbUnit; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgba", function() { return rgba; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hsla", function() { return hsla; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hex", function() { return hex; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "color", function() { return color; }); /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. 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 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ var __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; var clamp = function (min, max) { return function (v) { return Math.max(Math.min(v, max), min); }; }; var contains = function (term) { return function (v) { return (typeof v === 'string' && v.indexOf(term) !== -1); }; }; var createUnitType = function (unit) { return ({ test: contains(unit), parse: parseFloat, transform: function (v) { return "" + v + unit; } }); }; var isFirstChars = function (term) { return function (v) { return (typeof v === 'string' && v.indexOf(term) === 0); }; }; var getValueFromFunctionString = function (value) { return value.substring(value.indexOf('(') + 1, value.lastIndexOf(')')); }; var splitCommaDelimited = function (value) { return typeof value === 'string' ? value.split(/,\s*/) : [value]; }; function splitColorValues(terms) { var numTerms = terms.length; return function (v) { var values = {}; var valuesArray = splitCommaDelimited(getValueFromFunctionString(v)); for (var i = 0; i < numTerms; i++) { values[terms[i]] = (valuesArray[i] !== undefined) ? parseFloat(valuesArray[i]) : 1; } return values; }; } var number = { test: function (v) { return typeof v === 'number'; }, parse: parseFloat, transform: function (v) { return v; } }; var alpha = __assign({}, number, { transform: clamp(0, 1) }); var degrees = createUnitType('deg'); var percent = createUnitType('%'); var px = createUnitType('px'); var scale = __assign({}, number, { default: 1 }); var FLOAT_REGEX = /(-)?(\d[\d\.]*)/g; var generateToken = function (token) { return '${' + token + '}'; }; var complex = { test: function (v) { var matches = v.match && v.match(FLOAT_REGEX); return (matches !== undefined && matches.constructor === Array && matches.length > 1); }, parse: function (v) { var parsedValue = {}; v.match(FLOAT_REGEX).forEach(function (value, i) { return parsedValue[i] = parseFloat(value); }); return parsedValue; }, createTransformer: function (prop) { var counter = 0; var template = prop.replace(FLOAT_REGEX, function () { return generateToken("" + counter++); }); return function (v) { var output = template; for (var key in v) { if (v.hasOwnProperty(key)) { output = output.replace(generateToken(key), v[key].toString()); } } return output; }; } }; var clampRgbUnit = clamp(0, 255); var rgbUnit = __assign({}, number, { transform: function (v) { return Math.round(clampRgbUnit(v)); } }); var rgbaTemplate = function (_a) { var red = _a.red, green = _a.green, blue = _a.blue, _b = _a.alpha, alpha = _b === void 0 ? 1 : _b; return "rgba(" + red + ", " + green + ", " + blue + ", " + alpha + ")"; }; var rgba = { test: isFirstChars('rgb'), parse: splitColorValues(['red', 'green', 'blue', 'alpha']), transform: function (_a) { var red = _a.red, green = _a.green, blue = _a.blue, alpha = _a.alpha; return rgbaTemplate({ red: rgbUnit.transform(red), green: rgbUnit.transform(green), blue: rgbUnit.transform(blue), alpha: alpha }); } }; var hslaTemplate = function (_a) { var hue = _a.hue, saturation = _a.saturation, lightness = _a.lightness, _b = _a.alpha, alpha = _b === void 0 ? 1 : _b; return "hsla(" + hue + ", " + saturation + ", " + lightness + ", " + alpha + ")"; }; var hsla = { test: isFirstChars('hsl'), parse: splitColorValues(['hue', 'saturation', 'lightness', 'alpha']), transform: function (_a) { var hue = _a.hue, saturation = _a.saturation, lightness = _a.lightness, alpha = _a.alpha; return hslaTemplate({ hue: Math.round(hue), saturation: percent.transform(saturation), lightness: percent.transform(lightness), alpha: alpha }); } }; var hex = __assign({}, rgba, { test: isFirstChars('#'), parse: function (v) { var r, g, b; if (v.length > 4) { r = v.substr(1, 2); g = v.substr(3, 2); b = v.substr(5, 2); } else { r = v.substr(1, 1); g = v.substr(2, 1); b = v.substr(3, 1); r += r; g += g; b += b; } return { red: parseInt(r, 16), green: parseInt(g, 16), blue: parseInt(b, 16), alpha: 1 }; } }); var isRgba = function (v) { return v.red !== undefined; }; var isHsla = function (v) { return v.hue !== undefined; }; var color = { test: function (v) { return rgba.test(v) || hsla.test(v) || hex.test(v); }, parse: function (v) { if (rgba.test(v)) { return rgba.parse(v); } else if (hsla.test(v)) { return hsla.parse(v); } else if (hex.test(v)) { return hex.parse(v); } return v; }, transform: function (v) { if (isRgba(v)) { return rgba.transform(v); } else if (isHsla(v)) { return hsla.transform(v); } return v; }, }; /***/ }), /* 5 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var isNum = function (v) { return typeof v === 'number'; }; exports.isPoint = function (point) { return point.x !== undefined && point.y !== undefined; }; exports.isPoint3D = function (point) { return point.z !== undefined; }; var toDecimal = function (num, precision) { if (precision === void 0) { precision = 2; } precision = Math.pow(10, precision); return Math.round(num * precision) / precision; }; var ZERO_POINT = { x: 0, y: 0, z: 0 }; var distance1D = function (a, b) { return Math.abs(a - b); }; exports.angle = function (a, b) { if (b === void 0) { b = ZERO_POINT; } return exports.radiansToDegrees(Math.atan2(b.y - a.y, b.x - a.x)); }; exports.degreesToRadians = function (degrees) { return degrees * Math.PI / 180; }; exports.dilate = function (a, b, dilation) { return a + ((b - a) * dilation); }; exports.distance = function (a, b) { if (b === void 0) { b = ZERO_POINT; } if (isNum(a) && isNum(b)) { return distance1D(a, b); } else if (exports.isPoint(a) && exports.isPoint(b)) { var xDelta = distance1D(a.x, b.x); var yDelta = distance1D(a.y, b.y); var zDelta = (exports.isPoint3D(a) && exports.isPoint3D(b)) ? distance1D(a.z, b.z) : 0; return Math.sqrt((Math.pow(xDelta, 2)) + (Math.pow(yDelta, 2)) + (Math.pow(zDelta, 2))); } return 0; }; exports.getProgressFromValue = function (from, to, value) { var toFromDifference = to - from; return toFromDifference === 0 ? 1 : (value - from) / toFromDifference; }; exports.getValueFromProgress = function (from, to, progress) { return (-progress * from) + (progress * to) + from; }; exports.pointFromAngleAndDistance = function (origin, angle, distance) { angle = exports.degreesToRadians(angle); return { x: distance * Math.cos(angle) + origin.x, y: distance * Math.sin(angle) + origin.y }; }; exports.radiansToDegrees = function (radians) { return radians * 180 / Math.PI; }; exports.smooth = function (newValue, oldValue, duration, smoothing) { if (smoothing === void 0) { smoothing = 0; } return toDecimal(oldValue + (duration * (newValue - oldValue) / Math.max(smoothing, duration))); }; exports.speedPerFrame = function (xps, frameDuration) { return (isNum(xps)) ? xps / (1000 / frameDuration) : 0; }; exports.speedPerSecond = function (velocity, frameDuration) { return frameDuration ? velocity * (1000 / frameDuration) : 0; }; exports.stepProgress = function (steps, progress) { var segment = 1 / (steps - 1); var target = 1 - (1 / steps); var progressOfTarget = Math.min(progress / target, 1); return Math.floor(progressOfTarget / segment) * segment; }; //# sourceMappingURL=calc.js.map /***/ }), /* 6 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return FlipContext; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(7); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_prop_types__ = __webpack_require__(8); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_prop_types___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_prop_types__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__flipHelpers__ = __webpack_require__(20); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_popmotion_easing__ = __webpack_require__(2); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_popmotion_easing___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_popmotion_easing__); var _class, _temp2; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var FlipContext = __WEBPACK_IMPORTED_MODULE_0_react___default.a.createContext("flip"); var Flipper = (_temp2 = _class = function (_Component) { _inherits(Flipper, _Component); function Flipper() { var _temp, _this, _ret; _classCallCheck(this, Flipper); for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.inProgressAnimations = {}, _this.flipCallbacks = {}, _temp), _possibleConstructorReturn(_this, _ret); } Flipper.prototype.getSnapshotBeforeUpdate = function getSnapshotBeforeUpdate(prevProps) { if (prevProps.flipKey !== this.props.flipKey) { return Object(__WEBPACK_IMPORTED_MODULE_2__flipHelpers__["b" /* getFlippedElementPositions */])(this.el); } return null; }; Flipper.prototype.componentDidUpdate = function componentDidUpdate(prevProps, prevState, cachedFlipChildrenPositions) { if (this.props.flipKey !== prevProps.flipKey) { this.inProgressAnimations = Object(__WEBPACK_IMPORTED_MODULE_2__flipHelpers__["a" /* animateMove */])({ cachedFlipChildrenPositions: cachedFlipChildrenPositions, containerEl: this.el, duration: this.props.duration, ease: __WEBPACK_IMPORTED_MODULE_3_popmotion_easing__[this.props.ease], inProgressAnimations: this.inProgressAnimations, flipCallbacks: this.flipCallbacks }); } }; Flipper.prototype.render = function render() { var _this2 = this; return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement( FlipContext.Provider, { value: this.flipCallbacks }, __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement( "div", { ref: function ref(el) { return _this2.el = el; } }, this.props.children ) ); }; return Flipper; }(__WEBPACK_IMPORTED_MODULE_0_react__["Component"]), _class.propTypes = { flipKey: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.oneOfType([__WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.string, __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.number, __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.bool]), children: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.node.isRequired, duration: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.number, ease: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.string }, _class.defaultProps = { duration: 250, ease: "easeOut" }, _temp2); /* harmony default export */ __webpack_exports__["b"] = (Flipper); /***/ }), /* 7 */ /***/ (function(module, exports) { module.exports = __WEBPACK_EXTERNAL_MODULE_7__; /***/ }), /* 8 */ /***/ (function(module, exports, __webpack_require__) { /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ if (true) { var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element')) || 0xeac7; var isValidElement = function(object) { return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; }; // By explicitly using `prop-types` you are opting into new development behavior. // http://fb.me/prop-types-in-prod var throwOnDirectAccess = true; module.exports = __webpack_require__(17)(isValidElement, throwOnDirectAccess); } else { // By explicitly using `prop-types` you are opting into new production behavior. // http://fb.me/prop-types-in-prod module.exports = require('./factoryWithThrowingShims')(); } /***/ }), /* 9 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * */ function makeEmptyFunction(arg) { return function () { return arg; }; } /** * This function accepts and discards inputs; it has no side effects. This is * primarily useful idiomatically for overridable function endpoints which * always need to be callable, since JS lacks a null-call idiom ala Cocoa. */ var emptyFunction = function emptyFunction() {}; emptyFunction.thatReturns = makeEmptyFunction; emptyFunction.thatReturnsFalse = makeEmptyFunction(false); emptyFunction.thatReturnsTrue = makeEmptyFunction(true); emptyFunction.thatReturnsNull = makeEmptyFunction(null); emptyFunction.thatReturnsThis = function () { return this; }; emptyFunction.thatReturnsArgument = function (arg) { return arg; }; module.exports = emptyFunction; /***/ }), /* 10 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ /** * Use invariant() to assert state which your program assumes to be true. * * Provide sprintf-style format (only %s is supported) and arguments * to provide information about what broke and what you were * expecting. * * The invariant message will be stripped in production, but the invariant * will remain to ensure logic does not differ in production. */ var validateFormat = function validateFormat(format) {}; if (true) { validateFormat = function validateFormat(format) { if (format === undefined) { throw new Error('invariant requires an error message argument'); } }; } function invariant(condition, format, a, b, c, d, e, f) { validateFormat(format); if (!condition) { var error; if (format === undefined) { error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.'); } else { var args = [a, b, c, d, e, f]; var argIndex = 0; error = new Error(format.replace(/%s/g, function () { return args[argIndex++]; })); error.name = 'Invariant Violation'; } error.framesToPop = 1; // we don't care about invariant's own frame throw error; } } module.exports = invariant; /***/ }), /* 11 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /** * Copyright (c) 2014-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ var emptyFunction = __webpack_require__(9); /** * Similar to invariant but only logs a warning if the condition is not met. * This can be used to log issues in development environments in critical * paths. Removing the logging code for production environments will keep the * same logic and follow the same code paths. */ var warning = emptyFunction; if (true) { var printWarning = function printWarning(format) { for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } var argIndex = 0; var message = 'Warning: ' + format.replace(/%s/g, function () { return args[argIndex++]; }); if (typeof console !== 'undefined') { console.error(message); } try { // --- Welcome to debugging React --- // This error was thrown as a convenience so that you can use this stack // to find the callsite that caused this warning to fire. throw new Error(message); } catch (x) {} }; warning = function warning(condition, format) { if (format === undefined) { throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); } if (format.indexOf('Failed Composite propType: ') === 0) { return; // Ignore CompositeComponent proptype check. } if (!condition) { for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { args[_key2 - 2] = arguments[_key2]; } printWarning.apply(undefined, [format].concat(args)); } }; } module.exports = warning; /***/ }), /* 12 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; module.exports = ReactPropTypesSecret; /***/ }), /* 13 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var framesync_1 = __webpack_require__(0); var action_1 = __webpack_require__(1); var multi = function (_a) { var getCount = _a.getCount, getFirst = _a.getFirst, getOutput = _a.getOutput, mapApi = _a.mapApi, setProp = _a.setProp, startActions = _a.startActions; return function (actions) { return action_1.default(function (_a) { var update = _a.update, complete = _a.complete, error = _a.error; var numActions = getCount(actions); var output = getOutput(); var updateOutput = function () { return update(output); }; var numCompletedActions = 0; var subs = startActions(actions, function (a, name) { var hasCompleted = false; return a.start({ complete: function () { if (!hasCompleted) { hasCompleted = true; numCompletedActions++; if (numCompletedActions === numActions) framesync_1.onFrameUpdate(complete); } }, error: error, update: function (v) { setProp(output, name, v); framesync_1.onFrameUpdate(updateOutput, true); } }); }); return Object.keys(getFirst(subs)).reduce(function (api, methodName) { api[methodName] = mapApi(subs, methodName); return api; }, {}); }); }; }; exports.default = multi; //# sourceMappingURL=multi.js.map /***/ }), /* 14 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var multi_1 = __webpack_require__(13); var parallel = multi_1.default({ getOutput: function () { return ([]); }, getCount: function (subs) { return subs.length; }, getFirst: function (subs) { return subs[0]; }, mapApi: function (subs, methodName) { return function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } return subs.map(function (sub, i) { if (sub[methodName]) { return Array.isArray(args[0]) ? sub[methodName](args[0][i]) : sub[methodName].apply(sub, args); } }); }; }, setProp: function (output, name, v) { return output[name] = v; }, startActions: function (actions, starter) { return actions.map(function (action, i) { return starter(action, i); }); } }); exports.default = (function () { var actions = []; for (var _i = 0; _i < arguments.length; _i++) { actions[_i] = arguments[_i]; } return parallel(actions); }); //# sourceMappingURL=parallel.js.map /***/ }), /* 15 */ /***/ (function(module, exports, __webpack_require__) { module.exports = __webpack_require__(16); /***/ }), /* 16 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Flipper__ = __webpack_require__(6); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Flipper", function() { return __WEBPACK_IMPORTED_MODULE_0__Flipper__["b"]; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Flipped__ = __webpack_require__(29); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Flipped", function() { return __WEBPACK_IMPORTED_MODULE_1__Flipped__["a"]; }); /***/ }), /* 17 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var emptyFunction = __webpack_require__(9); var invariant = __webpack_require__(10); var warning = __webpack_require__(11); var assign = __webpack_require__(18); var ReactPropTypesSecret = __webpack_require__(12); var checkPropTypes = __webpack_require__(19); module.exports = function(isValidElement, throwOnDirectAccess) { /* global Symbol */ var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec. /** * Returns the iterator method function contained on the iterable object. * * Be sure to invoke the function with the iterable as context: * * var iteratorFn = getIteratorFn(myIterable); * if (iteratorFn) { * var iterator = iteratorFn.call(myIterable); * ... * } * * @param {?object} maybeIterable * @return {?function} */ function getIteratorFn(maybeIterable) { var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeI