Moving hotspots i.e View over scaled & panned Image.

79 views Asked by At

I have been working on for panning the image in a container for which I am using TouchImageView. What I am trying to achieve is that I want to translate some other view with respect to the amount of panning i.e translation made.

Below is the ACTION_MOVE Event when 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 issue I am facing is all works well while translating the tags over panned image. But when the Image has reached its bounds it still get translationX or translationY values greater/less than 0 which makes my tags move out of bound. Is there any way I can restrict the extra translation.? I have tried with matrix method. I still get the translation values above 0 after I reach its bounds when the image is scaled.

0

There are 0 answers