trap method

int trap(
  1. int pos
)

Constrains the graph offset within valid bounds. pos is the proposed offset value. Returns clamped offset between 0 and maximum data points.

Implementation

int trap(int pos) {
  if (pos < 0) {
    return 0;
  } else if (pos > widget.test.bpmEntries!.length)
    pos = widget.test.bpmEntries!.length;

  return pos;
}