UNPKG

@tamagui/react-native-web-lite

Version:
302 lines (301 loc) 8.34 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: !0 }); }, __copyProps = (to, from, except, desc) => { if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target, mod )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod); var Easing_exports = {}; __export(Easing_exports, { default: () => Easing_default }); module.exports = __toCommonJS(Easing_exports); var import_bezier = __toESM(require("./bezier")); function _class_call_check(instance, Constructor) { if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0, "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor); } } function _create_class(Constructor, protoProps, staticProps) { return protoProps && _defineProperties(Constructor.prototype, protoProps), staticProps && _defineProperties(Constructor, staticProps), Constructor; } var ease, Easing = /* @__PURE__ */ function() { function Easing2() { _class_call_check(this, Easing2); } return _create_class(Easing2, null, [ { key: "step0", value: ( /** * A stepping function, returns 1 for any positive value of `n`. */ function(n) { return n > 0 ? 1 : 0; } ) }, { key: "step1", value: ( /** * A stepping function, returns 1 if `n` is greater than or equal to 1. */ function(n) { return n >= 1 ? 1 : 0; } ) }, { key: "linear", value: ( /** * A linear function, `f(t) = t`. Position correlates to elapsed time one to * one. * * http://cubic-bezier.com/#0,0,1,1 */ function(t) { return t; } ) }, { key: "ease", value: ( /** * A simple inertial interaction, similar to an object slowly accelerating to * speed. * * http://cubic-bezier.com/#.42,0,1,1 */ function(t) { return ease || (ease = Easing2.bezier(0.42, 0, 1, 1)), ease(t); } ) }, { key: "quad", value: ( /** * A quadratic function, `f(t) = t * t`. Position equals the square of elapsed * time. * * http://easings.net/#easeInQuad */ function(t) { return t * t; } ) }, { key: "cubic", value: ( /** * A cubic function, `f(t) = t * t * t`. Position equals the cube of elapsed * time. * * http://easings.net/#easeInCubic */ function(t) { return t * t * t; } ) }, { key: "poly", value: ( /** * A power function. Position is equal to the Nth power of elapsed time. * * n = 4: http://easings.net/#easeInQuart * n = 5: http://easings.net/#easeInQuint */ function(n) { return function(t) { return Math.pow(t, n); }; } ) }, { key: "sin", value: ( /** * A sinusoidal function. * * http://easings.net/#easeInSine */ function(t) { return 1 - Math.cos(t * Math.PI / 2); } ) }, { key: "circle", value: ( /** * A circular function. * * http://easings.net/#easeInCirc */ function(t) { return 1 - Math.sqrt(1 - t * t); } ) }, { key: "exp", value: ( /** * An exponential function. * * http://easings.net/#easeInExpo */ function(t) { return Math.pow(2, 10 * (t - 1)); } ) }, { key: "elastic", value: ( /** * A simple elastic interaction, similar to a spring oscillating back and * forth. * * Default bounciness is 1, which overshoots a little bit once. 0 bounciness * doesn't overshoot at all, and bounciness of N > 1 will overshoot about N * times. * * http://easings.net/#easeInElastic */ function() { var bounciness = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1, p = bounciness * Math.PI; return function(t) { return 1 - Math.pow(Math.cos(t * Math.PI / 2), 3) * Math.cos(t * p); }; } ) }, { key: "back", value: ( /** * Use with `Animated.parallel()` to create a simple effect where the object * animates back slightly as the animation starts. * * Wolfram Plot: * * - http://tiny.cc/back_default (s = 1.70158, default) */ function() { var s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1.70158; return function(t) { return t * t * ((s + 1) * t - s); }; } ) }, { key: "bounce", value: ( /** * Provides a simple bouncing effect. * * http://easings.net/#easeInBounce */ function(t) { if (t < 1 / 2.75) return 7.5625 * t * t; if (t < 2 / 2.75) { var t2 = t - 0.5454545454545454; return 7.5625 * t2 * t2 + 0.75; } if (t < 2.5 / 2.75) { var t21 = t - 0.8181818181818182; return 7.5625 * t21 * t21 + 0.9375; } var t22 = t - 2.625 / 2.75; return 7.5625 * t22 * t22 + 0.984375; } ) }, { key: "bezier", value: ( /** * Provides a cubic bezier curve, equivalent to CSS Transitions' * `transition-timing-function`. * * A useful tool to visualize cubic bezier curves can be found at * http://cubic-bezier.com/ */ function(x1, y1, x2, y2) { return (0, import_bezier.default)(x1, y1, x2, y2); } ) }, { key: "in", value: ( /** * Runs an easing function forwards. */ function(easing) { return easing; } ) }, { key: "out", value: ( /** * Runs an easing function backwards. */ function(easing) { return function(t) { return 1 - easing(1 - t); }; } ) }, { key: "inOut", value: ( /** * Makes any easing function symmetrical. The easing function will run * forwards for half of the duration, then backwards for the rest of the * duration. */ function(easing) { return function(t) { return t < 0.5 ? easing(t * 2) / 2 : 1 - easing((1 - t) * 2) / 2; }; } ) } ]), Easing2; }(), Easing_default = Easing; //# sourceMappingURL=Easing.js.map