Image zoom and pan in mobile app

NOVASOLUTIONS.TECHNOLOGY is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
Image zoom and pan in mobile app
Medium
from 1 business day to 3 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    756
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1052
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    862
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    445

Implementing Image Zoom and Pan in Mobile Application

Zoom and pan look like two gesture recognizers. In reality it's a connected transformation system that must work smoothly at 60 fps, not conflict with other app gestures and correctly handle edge cases — double tap, image boundaries during pan, return to original state.

Technical Implementation Details

React Native — react-native-gesture-handler + react-native-reanimated. Standard <Image> doesn't support gesture transformations — need Animated.Image or Reanimated. Approach with useSharedValue for scale and translateX/Y, useGestureHandler for PinchGesture + PanGesture:

const scale = useSharedValue(1);
const translateX = useSharedValue(0);
const translateY = useSharedValue(0);

const pinchGesture = Gesture.Pinch()
  .onUpdate((e) => {
    scale.value = clamp(savedScale.value * e.scale, 1, 5);
  })
  .onEnd(() => {
    savedScale.value = scale.value;
    if (scale.value < 1) {
      scale.value = withSpring(1);
    }
  });

Gesture.Simultaneous(pinchGesture, panGesture) allows pinch and pan simultaneously. Gesture.Race() — if you need to divide by priority.

Pan boundary limitation. At zoom x3, 375px image becomes 1125px. Max allowed translateX = (scaledWidth - containerWidth) / 2. Without this check user drags image off screen. Bounds checking in onUpdate via clamp():

const maxTranslateX = (containerWidth * (scale.value - 1)) / 2;
translateX.value = clamp(translateX.value + delta, -maxTranslateX, maxTranslateX);

Flutter — InteractiveViewer. Built-in Flutter widget with minScale, maxScale, boundaryMargin. For basic case sufficient. For gallery with multiple images — InteractiveViewer inside PageView, but horizontal swipe for photo change vs horizontal pan on zoom conflict. Solution: InteractiveViewer intercepts pan only when scale > 1; at scale == 1 gesture passes to PageView.

iOS native — UIPinchGestureRecognizer + UIPanGestureRecognizer. gestureRecognizer.require(toFail:) for conflict resolution. CGAffineTransform for transformations to UIImageView. UIScrollView + UIScrollViewDelegate.viewForZooming — alternative getting bounce at bounds and zoomRect animations free.

Double Tap

Double tap: if scale == 1 — zoom to 2–3x at tap location. If already zoomed — return to scale == 1. Animation via withSpring (for "rubber" feel) or withTiming with Easing.out(Easing.cubic).

Zoom point from tap coordinates relative to image:

const focalX = tapEvent.x - containerWidth / 2;
const focalY = tapEvent.y - containerHeight / 2;
translateX.value = withSpring(-focalX * (targetScale - 1));

From practice: medical imaging viewer app, React Native. Zoom on high-resolution X-ray images (4096×4096px). Loading fullsize image in Image component caused OutOfMemoryError on Android. Solution: react-native-fast-image with resizeMode="contain" for preview + tile-based loading of fullsize via react-native-zoom-toolkit with Deep Zoom format support.

Gallery with Zoom

Gallery: horizontal FlatList with pagingEnabled={true} (or ViewPager on Android). Each element — zoomable image. Horizontal pan conflict during zoom — resolve via activeOffsetX in Pan gesture handler: pan activates only on > 10px shift horizontally; while scale > 1 block page swipe.

What's Included

  • Pinch-to-zoom with min/max scale limit (usually 1x–5x)
  • Pan on zoomed image with boundary limits
  • Double tap — zoom in/out with animation to tap point
  • Bounce-return when exceeding boundaries
  • Integration into gallery/carousel with correct gesture conflict resolution
  • High-resolution image support without OutOfMemoryError

Timeline

1–3 working days — single image with zoom. With gallery and gesture conflict resolution — 2–3 days. Cost calculated individually.