defaultSlidePageBackgroundHandler function
ExtendedImageGesturePage
Implementation
Color defaultSlidePageBackgroundHandler({
Offset offset = Offset.zero,
Size pageSize = const Size(100, 100),
required Color color,
SlideAxis pageGestureAxis = SlideAxis.both,
}) {
double opacity = 0.0;
if (pageGestureAxis == SlideAxis.both) {
opacity = offset.distance /
(Offset(pageSize.width, pageSize.height).distance / 2.0);
} else if (pageGestureAxis == SlideAxis.horizontal) {
opacity = offset.dx.abs() / (pageSize.width / 2.0);
} else if (pageGestureAxis == SlideAxis.vertical) {
opacity = offset.dy.abs() / (pageSize.height / 2.0);
}
return color.withOpacity(min(1.0, max(1.0 - opacity, 0.0)));
}