ixfx
    Preparing search index...

    Function point

    • A tracked point. Create via Trackers.point. Mutable. Useful for monitoring how it changes over time. Eg. when a pointerdown event happens, to record the start position and then track the pointer as it moves until pointerup.

      See also

      import { point } from 'https://unpkg.com/ixfx/dist/trackers.js';

      // Create a tracker on a pointerdown
      const t = point();

      // ...and later, tell it when a point is seen (eg. pointermove)
      const nfo = t.seen({x: evt.x, y:evt.y});
      // nfo gives us some details on the relation between the seen point, the start, and points inbetween
      // nfo.angle, nfo.centroid, nfo.speed etc.

      Compute based on last seen point

      t.angleFromStart();
      t.distanceFromStart();
      t.x / t.y
      t.length; // Total length of accumulated points
      t.elapsed; // Total duration since start
      t.lastResult; // The PointSeenInfo for last seen point

      Housekeeping

      t.reset(); // Reset tracker
      

      By default, the tracker only keeps track of the initial point and does not store intermediate 'seen' points. To use the tracker as a buffer, set storeIntermediate option to true.

      // Keep only the last 10 points
      const t = point({
      sampleLimit: 10
      });

      // Store all 'seen' points
      const t = point({
      storeIntermediate: true
      });

      // In this case, the whole tracker is automatically
      // reset after 10 samples
      const t = point({
      resetAfterSamples: 10
      })

      When using a buffer limited by sampleLimit, the 'initial' point will be the oldest in the buffer, not actually the very first point seen.

      Parameters

      Returns PointTracker