ImageMatrixTouchHandler.java 文件源码

java
阅读 46 收藏 0 点赞 0 评论 0

项目:PinchToZoom 作者:
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
    if (mode == DRAG) {
        if (flingDuration > 0 && !isAnimating()) {
            float factor = ((float) flingDuration / 1000f) * flingExaggeration;
            float[] values = corrector.getValues();
            float dx = (velocityX * factor) * values[Matrix.MSCALE_X];
            float dy = (velocityY * factor) * values[Matrix.MSCALE_Y];
            PropertyValuesHolder flingX = PropertyValuesHolder.ofFloat(FlingAnimatorHandler.PROPERTY_TRANSLATE_X, values[Matrix.MTRANS_X], values[Matrix.MTRANS_X] + dx);
            PropertyValuesHolder flingY = PropertyValuesHolder.ofFloat(FlingAnimatorHandler.PROPERTY_TRANSLATE_Y, values[Matrix.MTRANS_Y], values[Matrix.MTRANS_Y] + dy);
            valueAnimator = ValueAnimator.ofPropertyValuesHolder(flingX, flingY);
            valueAnimator.setDuration(flingDuration);
            valueAnimator.addUpdateListener(new FlingAnimatorHandler(corrector));
            valueAnimator.setInterpolator(new DecelerateInterpolator());
            valueAnimator.start();
            return true;
        }
    }
    return super.onFling(e1, e2, velocityX, velocityY);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号