Home / File/ VectorWidget.js — react Source File

VectorWidget.js — react Source File

Architecture documentation for VectorWidget.js, a javascript file in the react codebase.

Entity Profile

Relationship Graph

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
'use strict';

var Circle = require('react-art/Circle');
var React = require('react');
var ReactART = require('react-art');
var Group = ReactART.Group;
var Shape = ReactART.Shape;
var Surface = ReactART.Surface;
var Transform = ReactART.Transform;

var MOUSE_UP_DRAG = 0.978;
var MOUSE_DOWN_DRAG = 0.9;
var MAX_VEL = 11;
var CLICK_ACCEL = 3;
var BASE_VEL = 0.15;

/**
 * An animated SVG component.
 */
class VectorWidget extends React.Component {
  /**
   * Initialize state members.
   */
  state = {degrees: 0, velocity: 0, drag: MOUSE_UP_DRAG};

  /**
   * When the component is mounted into the document - this is similar to a
   * constructor, but invoked when the instance is actually mounted into the
   * document. Here, we'll just set up an animation loop that invokes our
   * method. Binding of `this.onTick` is not needed because all React methods
   * are automatically bound before being mounted.
   */
  componentDidMount() {
    this._interval = window.setInterval(this.onTick, 20);
  }

  componentWillUnmount() {
    window.clearInterval(this._interval);
  }

  onTick = () => {
    var nextDegrees = this.state.degrees + BASE_VEL + this.state.velocity;
    var nextVelocity = this.state.velocity * this.state.drag;
    this.setState({degrees: nextDegrees, velocity: nextVelocity});
  };

  /**
   * When mousing down, we increase the friction down the velocity.
   */
  handleMouseDown = () => {
    this.setState({drag: MOUSE_DOWN_DRAG});
  };

  /**
// ... (89 more lines)

Domain

Subdomains

Classes

Frequently Asked Questions

What does VectorWidget.js do?
VectorWidget.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Optimization subdomain.
Where is VectorWidget.js in the architecture?
VectorWidget.js is located at fixtures/art/VectorWidget.js (domain: BabelCompiler, subdomain: Optimization, directory: fixtures/art).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free