public void OnUpdate()
        {
            if (draggingPointerEventData == null)
            {
                return;
            }

            Vector2 pointerLocalPos;

            RectTransformUtility.ScreenPointToLocalPointInRectangle(manager.Viewport, draggingPointerEventData.position, draggingPointerEventData.pressEventCamera, out pointerLocalPos);

            bool  shouldUpdateViewport = false;
            float scale = manager.ImageHolder.localScale.z;

            Vector2 imagePosition       = manager.ImageHolder.anchoredPosition;
            Vector2 selectionBottomLeft = imagePosition + selection.anchoredPosition * scale;
            Vector2 selectionTopRight   = selectionBottomLeft + selection.sizeDelta * scale;

            Vector2 viewportSize = manager.ViewportSize;

            if ((directions & Direction.Left) == Direction.Left || (directions & Direction.Right) == Direction.Right)
            {
                if (pointerLocalPos.x <= SCROLL_DISTANCE && selectionBottomLeft.x <= SELECTION_MAX_DISTANCE_FOR_SCROLL)
                {
                    imagePosition        = manager.ScrollImage(imagePosition, Direction.Left);
                    shouldUpdateViewport = true;
                }
                else if (pointerLocalPos.x >= viewportSize.x - SCROLL_DISTANCE && selectionTopRight.x >= viewportSize.x - SELECTION_MAX_DISTANCE_FOR_SCROLL)
                {
                    imagePosition        = manager.ScrollImage(imagePosition, Direction.Right);
                    shouldUpdateViewport = true;
                }
            }

            if ((directions & Direction.Bottom) == Direction.Bottom || (directions & Direction.Top) == Direction.Top)
            {
                if (pointerLocalPos.y <= SCROLL_DISTANCE && selectionBottomLeft.y <= SELECTION_MAX_DISTANCE_FOR_SCROLL)
                {
                    imagePosition        = manager.ScrollImage(imagePosition, Direction.Bottom);
                    shouldUpdateViewport = true;
                }
                else if (pointerLocalPos.y >= viewportSize.y - SCROLL_DISTANCE && selectionTopRight.y >= viewportSize.y - SELECTION_MAX_DISTANCE_FOR_SCROLL)
                {
                    imagePosition        = manager.ScrollImage(imagePosition, Direction.Top);
                    shouldUpdateViewport = true;
                }
            }

            if (shouldUpdateViewport)
            {
                manager.ImageHolder.anchoredPosition = imagePosition;
                OnDrag(draggingPointerEventData);
            }
        }
        public void OnUpdate()
        {
            bool  shouldUpdateViewport = false;
            float scale = manager.ImageHolder.localScale.z;

            Vector2 imagePosition       = manager.ImageHolder.anchoredPosition;
            Vector2 selectionBottomLeft = imagePosition + selection.anchoredPosition * scale;
            Vector2 selectionTopRight   = selectionBottomLeft + selection.sizeDelta * scale;
            Vector2 selectionSize       = selectionTopRight - selectionBottomLeft;

            Vector2 viewportSize = manager.ViewportSize;

            if (selectionBottomLeft.x <= SCROLL_DISTANCE)
            {
                imagePosition         = manager.ScrollImage(imagePosition, Direction.Left);
                selectionBottomLeft.x = 0f;

                shouldUpdateViewport = true;
            }
            else if (selectionTopRight.x >= viewportSize.x - SCROLL_DISTANCE)
            {
                imagePosition         = manager.ScrollImage(imagePosition, Direction.Right);
                selectionBottomLeft.x = viewportSize.x - selectionSize.x;

                shouldUpdateViewport = true;
            }

            if (selectionBottomLeft.y <= SCROLL_DISTANCE)
            {
                imagePosition         = manager.ScrollImage(imagePosition, Direction.Bottom);
                selectionBottomLeft.y = 0f;

                shouldUpdateViewport = true;
            }
            else if (selectionTopRight.y >= viewportSize.y - SCROLL_DISTANCE)
            {
                imagePosition         = manager.ScrollImage(imagePosition, Direction.Top);
                selectionBottomLeft.y = viewportSize.y - selectionSize.y;

                shouldUpdateViewport = true;
            }

            if (shouldUpdateViewport)
            {
                manager.ImageHolder.anchoredPosition = imagePosition;
                manager.UpdateSelection((selectionBottomLeft - imagePosition) / scale);
            }
        }