Skip to content

Commit

Permalink
fixed smoothScaleTo bug
Browse files Browse the repository at this point in the history
this method should now work properly when called from outside the widget
  • Loading branch information
moagrius committed Oct 30, 2013
1 parent 122c086 commit 0a81b2a
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/com/qozix/layouts/ZoomPanLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,13 @@ public void smoothScaleTo( double destination, int duration ) {
if ( isTweening ) {
return;
}
doubleTapDestinationScale = destination;
tween.setDuration( duration );
tween.start();
saveHistoricalScale();
int x = (int) ( ( getWidth() * 0.5 ) + 0.5 );
int y = (int) ( ( getHeight() * 0.5 ) + 0.5 );
doubleTapStartOffset.set( x, y );
doubleTapStartScroll.set( getScrollX(), getScrollY() );
doubleTapStartScroll.offset( x, y );
startSmoothScaleTo( destination, duration );
}

//------------------------------------------------------------------------------------
Expand Down Expand Up @@ -693,6 +697,15 @@ private boolean determineIfQualifiedSingleTap() {
return !isTapInterrupted && ( Math.abs( firstFinger.x - singleTapHistory.x ) <= SINGLE_TAP_DISTANCE_THRESHOLD )
&& ( Math.abs( firstFinger.y - singleTapHistory.y ) <= SINGLE_TAP_DISTANCE_THRESHOLD );
}

private void startSmoothScaleTo( double destination, int duration ){
if ( isTweening ) {
return;
}
doubleTapDestinationScale = destination;
tween.setDuration( duration );
tween.start();
}

private void processEvent( MotionEvent event ) {

Expand Down Expand Up @@ -835,7 +848,7 @@ public boolean onTouchEvent( MotionEvent event ) {
saveHistoricalScale();
saveDoubleTapHistory();
double destination = Math.min( maxScale, scale * 2 );
smoothScaleTo( destination, ZOOM_ANIMATION_DURATION );
startSmoothScaleTo( destination, ZOOM_ANIMATION_DURATION );
for ( GestureListener listener : gestureListeners ) {
listener.onDoubleTap( actualPoint );
}
Expand Down

0 comments on commit 0a81b2a

Please sign in to comment.