UNPKG

confetti-explosion-react

Version:
35 lines 1.34 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.shouldBeCircle = exports.rotationTransforms = exports.coinFlip = exports.rotate = exports.mapRange = void 0; var lodash_isequal_1 = __importDefault(require("lodash.isequal")); var mapRange = function (value, x1, y1, x2, y2) { return ((value - x1) * (y2 - x2)) / (y1 - x1) + x2; }; exports.mapRange = mapRange; var rotate = function (degree, amount) { var result = degree + amount; return result > 360 ? result - 360 : result; }; exports.rotate = rotate; var coinFlip = function () { return Math.random() > 0.5; }; exports.coinFlip = coinFlip; // avoid this for circles, as it will have no visual effect var zAxisRotation = [0, 0, 1]; exports.rotationTransforms = [ // dual axis rotations (a bit more realistic) [1, 1, 0], [1, 0, 1], [0, 1, 1], // single axis rotations (a bit dumber) [1, 0, 0], [0, 1, 0], zAxisRotation, ]; var shouldBeCircle = function (rotationIndex) { return !(0, lodash_isequal_1.default)(exports.rotationTransforms[rotationIndex], zAxisRotation) && (0, exports.coinFlip)(); }; exports.shouldBeCircle = shouldBeCircle; //# sourceMappingURL=utils.js.map