Skip to content

Commit d85e5a8

Browse files
committed
优化缩放体验
1 parent 8a289c1 commit d85e5a8

File tree

1 file changed

+7
-3
lines changed
  • chart/src/main/java/cn/jingzhuan/lib/chart2/base

1 file changed

+7
-3
lines changed

chart/src/main/java/cn/jingzhuan/lib/chart2/base/Chart.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ public abstract class Chart extends BitmapCachedChart {
7575
* @see #zoomIn()
7676
* @see #zoomOut()
7777
*/
78-
private static final float ZOOM_AMOUNT = 0.25f;
78+
private static final float ZOOM_AMOUNT = 0.2f;
7979

80-
private Point mSurfaceSizeBuffer = new Point();
80+
private final Point mSurfaceSizeBuffer = new Point();
8181

8282

8383
// Edge effect / overscroll tracking objects.
@@ -222,6 +222,7 @@ private boolean hitTest(float x, float y, PointF dest) {
222222
if (!mContentRect.contains((int) x, (int) y)) {
223223
return false;
224224
}
225+
225226
dest.set(mCurrentViewport.left
226227
+ mCurrentViewport.width()
227228
* (x - mContentRect.left) / mContentRect.width(),
@@ -316,6 +317,7 @@ else if (zoomOut)
316317
mCurrentViewport.constrainViewport();
317318
triggerViewportChange();
318319
lastSpanX = spanX;
320+
319321
return true;
320322
}
321323
};
@@ -335,6 +337,7 @@ public boolean onDown(MotionEvent e) {
335337
releaseEdgeEffects();
336338
mScrollerStartViewport.set(mCurrentViewport);
337339
mScroller.forceFinished(true);
340+
338341
postInvalidateOnAnimation();
339342

340343
return true;
@@ -446,6 +449,8 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float ve
446449
};
447450

448451
protected void triggerViewportChange() {
452+
postInvalidateOnAnimation();
453+
449454
if (mInternalViewportChangeListener != null) {
450455
mInternalViewportChangeListener.onViewportChange(mCurrentViewport);
451456
}
@@ -460,7 +465,6 @@ protected void triggerViewportChange() {
460465
}
461466
}
462467
}
463-
postInvalidateOnAnimation();
464468
}
465469

466470
private void fling(int velocityX) {

0 commit comments

Comments
 (0)