UNPKG

@figliolia/rn-donut-chart

Version:
25 lines (24 loc) 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Controller = void 0; const Interpolation_1 = require("./Interpolation"); class Controller { static stateFrom(props) { const { circumference, rotation = 0, renderPhase } = props; return { drawInterpolation: new Interpolation_1.Interpolation(circumference, this.strokeDashoffset(props)), rotateInterpolation: this.rotationInterpolation(rotation, renderPhase), }; } static strokeDashoffset(props) { const { value, gap = 0, circumference } = props; return circumference * (1 - value) + gap; } static rotationInterpolation(rotation, renderPhase) { const toRotation = `${rotation}deg`; const fromRotation = renderPhase === "INITIAL" ? "0deg" : toRotation; return new Interpolation_1.Interpolation(fromRotation, toRotation); } } exports.Controller = Controller; Controller.opacityInterpolation = new Interpolation_1.Interpolation(0, 1);