setDelta method

void setDelta()

Implementation

void setDelta() {
  if (beginDragPosition == null || updateDragPosition == null) return;
  if (!viewIsSet || !boundIsSet) return;

  Offset _delta = delta + Offset(updateDragPosition!.dx - beginDragPosition!.dx, updateDragPosition!.dy - beginDragPosition!.dy);
  normalisedConstraintsMin = constraintsMin - viewOrigin! + boundOrigin!;
  normalisedConstraintsMax = constraintsMax - viewOrigin! + boundOrigin! - Offset(viewWidth, viewHeight);
  if (_delta.dx < normalisedConstraintsMin.dx) _delta = Offset(normalisedConstraintsMin.dx - pow((_delta.dx - normalisedConstraintsMin.dx).abs(), flexibilityMin.dx) + 1.0, _delta.dy);
  if (_delta.dx > normalisedConstraintsMax.dx) _delta = Offset(normalisedConstraintsMax.dx + pow((_delta.dx - normalisedConstraintsMax.dx).abs(), flexibilityMax.dx) - 1.0, _delta.dy);
  if (_delta.dy < normalisedConstraintsMin.dy) _delta = Offset(_delta.dx, normalisedConstraintsMin.dy - pow((_delta.dy - normalisedConstraintsMin.dy).abs(), flexibilityMin.dy) + 1.0);
  if (_delta.dy > normalisedConstraintsMax.dy) _delta = Offset(_delta.dx, normalisedConstraintsMax.dy + pow((_delta.dy - normalisedConstraintsMax.dy).abs(), flexibilityMax.dy) - 1.0);

  deltaNotifier.value = _delta;

  if (onMove != null) onMove!(deltaNotifier.value);
}