UNPKG

@figliolia/rn-donut-chart

Version:
21 lines (20 loc) 847 B
import { Interpolation } from "./Interpolation.js"; export class Controller { static opacityInterpolation = new Interpolation(0, 1); static stateFrom(props) { const { circumference, rotation = 0, renderPhase } = props; return { drawInterpolation: new 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(fromRotation, toRotation); } }