defaultSlidePageBackgroundHandler function

Color defaultSlidePageBackgroundHandler({
  1. Offset offset = Offset.zero,
  2. Size pageSize = const Size(100, 100),
  3. required Color color,
  4. SlideAxis pageGestureAxis = SlideAxis.both,
})

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)));
}