Skip to content

Commit

Permalink
davemorrissey#194 Configurable double tap zoom duration
Browse files Browse the repository at this point in the history
  • Loading branch information
davemorrissey committed Apr 3, 2016
1 parent af82d39 commit 3c96277
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ public class SubsamplingScaleImageView extends View {
// Double tap zoom behaviour
private float doubleTapZoomScale = 1F;
private int doubleTapZoomStyle = ZOOM_FOCUS_FIXED;
private int doubleTapZoomDuration = 500;

// Current scale and scale at start of zoom
private float scale;
Expand Down Expand Up @@ -842,9 +843,9 @@ private void doubleTapZoom(PointF sCenter, PointF vFocus) {
if (doubleTapZoomStyle == ZOOM_FOCUS_CENTER_IMMEDIATE) {
setScaleAndCenter(targetScale, sCenter);
} else if (doubleTapZoomStyle == ZOOM_FOCUS_CENTER || !zoomIn || !panEnabled) {
new AnimationBuilder(targetScale, sCenter).withInterruptible(false).start();
new AnimationBuilder(targetScale, sCenter).withInterruptible(false).withDuration(doubleTapZoomDuration).start();
} else if (doubleTapZoomStyle == ZOOM_FOCUS_FIXED) {
new AnimationBuilder(targetScale, sCenter, vFocus).withInterruptible(false).start();
new AnimationBuilder(targetScale, sCenter, vFocus).withInterruptible(false).withDuration(doubleTapZoomDuration).start();
}
invalidate();
}
Expand Down Expand Up @@ -2436,6 +2437,14 @@ public final void setDoubleTapZoomStyle(int doubleTapZoomStyle) {
this.doubleTapZoomStyle = doubleTapZoomStyle;
}

/**
* Set the duration of the double tap zoom animation.
* @param durationMs Duration in milliseconds.
*/
public final void setDoubleTapZoomDuration(int durationMs) {
this.doubleTapZoomDuration = Math.max(0, durationMs);
}

/**
* Toggle parallel loading. When enabled, tiles are loaded using the thread pool executor available
* in SDK 11+. In older versions this has no effect. Parallel loading may use more memory and there
Expand Down

0 comments on commit 3c96277

Please sign in to comment.