morphProjectValue function

double morphProjectValue(
  1. double value,
  2. double velocityPerSecond, {
  3. double decelerationRate = 0.998,
})

Momentum projection (WWDC18 "Designing Fluid Interfaces"): where the value would coast to under natural deceleration. The "close or return" decision is made from the projection, not from the current position.

Implementation

double morphProjectValue(
  double value,
  double velocityPerSecond, {
  double decelerationRate = 0.998,
}) {
  return value +
      velocityPerSecond / 1000 * decelerationRate / (1 - decelerationRate);
}