@figliolia/rn-donut-chart
Version:
An animated donut/pie chart library
25 lines (24 loc) • 1.03 kB
JavaScript
;
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);