Moving hotspots ie View zoomed and zoomed out.

I was working on panning an image in a container for which I am using a TouchImageView. I am trying to achieve that I want to translate some other view regarding the amount of panning done by the translation.

The following shows the ACTION_MOVE event when the user makes a pan event.

                 case MotionEvent.ACTION_MOVE:
                    if (state == State.DRAG) {
                        float deltaX = curr.x - last.x;
                        float deltaY = curr.y - last.y;
                        float fixTransX = getFixDragTrans(deltaX, viewWidth, getImageWidth());
                        float fixTransY = getFixDragTrans(deltaY, viewHeight, getImageHeight());


                        matrix.postTranslate(fixTransX, fixTransY);
                        fixTrans();

                        // this is my function for callbacks. 
                        // This is where I want to restrict callback if translation values from matrix is 0 after scaling / zooming
                        // but it still gives values > 0 if trying to pan.
                        moveViewsWithSameDistance(fixTransX, fixTransY);

                        last.set(curr.x, curr.y);
                    }
                    break;

      

The problem I ran into works well when translating tags to an image. But when the image reaches its bounds, it still gets translationX or translationY values ​​greater / less than 0, which causes my tags to go out of the anchor. Is there a way to limit additional translation? I've tried using the matrix method. I am still getting translation values ​​above 0 after reaching my bounds when scaling the image.

+3


source to share





All Articles