handleScaleUpdate method
Implementation
void handleScaleUpdate(ScaleUpdateDetails details) {
if (extendedImageSlidePageState != null &&
details.scale == 1.0 &&
(_gestureDetails!.totalScale ?? 1) <= 1 &&
_gestureDetails!.userOffset &&
_gestureDetails!.actionType == ActionType.pan) {
final Offset totalDelta = details.focalPointDelta;
bool updateGesture = false;
if (!extendedImageSlidePageState!.isSliding) {
if (totalDelta.dx != 0 &&
totalDelta.dx.abs().greaterThan(totalDelta.dy.abs())) {
if (_gestureDetails!.computeHorizontalBoundary) {
if (totalDelta.dx > 0) {
updateGesture = _gestureDetails!.boundary.left;
} else {
updateGesture = _gestureDetails!.boundary.right;
}
} else {
updateGesture = true;
}
}
if (totalDelta.dy != 0 &&
totalDelta.dy.abs().greaterThan(totalDelta.dx.abs())) {
if (_gestureDetails!.computeVerticalBoundary) {
if (totalDelta.dy < 0) {
updateGesture = _gestureDetails!.boundary.bottom;
} else {
updateGesture = _gestureDetails!.boundary.top;
}
} else {
updateGesture = true;
}
}
} else {
updateGesture = true;
}
final double delta = (details.focalPoint - _startingOffset).distance;
if (delta.greaterThan(minGesturePageDelta) && updateGesture) {
extendedImageSlidePageState!.slide(
details.focalPointDelta,
extendedImageGestureState: this,
);
}
}
if (extendedImageSlidePageState != null &&
extendedImageSlidePageState!.isSliding) {
return;
}
// totalScale > 1 and page view is starting to move
if (_pageViewState != null) {
final ExtendedImageGesturePageViewState pageViewState = _pageViewState!;
final Axis axis = pageViewState.widget.scrollDirection;
final bool movePage = _pageViewState!.isDraging ||
(details.pointerCount == 1 &&
details.scale == 1 &&
_gestureDetails!.movePage(details.focalPointDelta, axis));
if (movePage) {
if (!pageViewState.isDraging) {
pageViewState
.onDragDown(DragDownDetails(globalPosition: details.focalPoint));
pageViewState.onDragStart(
DragStartDetails(globalPosition: details.focalPoint));
//assert(!pageViewState.isDraging);
}
Offset delta = details.focalPointDelta;
delta =
axis == Axis.horizontal ? Offset(delta.dx, 0) : Offset(0, delta.dy);
pageViewState.onDragUpdate(DragUpdateDetails(
globalPosition: details.focalPoint,
delta: delta,
primaryDelta: axis == Axis.horizontal ? delta.dx : delta.dy,
));
return;
}
}
final double? scale = widget.canScaleImage(_gestureDetails)
? clampScale(
_startingScale! * details.scale * _gestureConfig!.speed,
_gestureConfig!.animationMinScale,
_gestureConfig!.animationMaxScale)
: _gestureDetails!.totalScale;
//Round the scale to three points after comma to prevent shaking
//scale = roundAfter(scale, 3);
//no more zoom
if (details.scale != 1.0 &&
((_gestureDetails!.totalScale!
.equalTo(_gestureConfig!.animationMinScale) &&
scale!.lessThanOrEqualTo(_gestureDetails!.totalScale!)) ||
(_gestureDetails!.totalScale!
.equalTo(_gestureConfig!.animationMaxScale) &&
scale!.greaterThanOrEqualTo(_gestureDetails!.totalScale!)))) {
return;
}
final Offset offset = (details.scale == 1.0
? details.focalPoint * _gestureConfig!.speed
: _startingOffset) -
_normalizedOffset * scale!;
if (mounted &&
(offset != _gestureDetails!.offset ||
scale != _gestureDetails!.totalScale)) {
gestureDetails = GestureDetails(
offset: offset,
totalScale: scale,
gestureDetails: _gestureDetails,
actionType: details.scale != 1.0 ? ActionType.zoom : ActionType.pan);
}
}