+ $: {
+ const pCanvas = modulo($topLeft.x, maxSize);
+ const qCanvas = modulo($topLeft.y, maxSize);
+
+ const pBoundary = pCanvas + Math.abs($topLeft.x - $bottomRight.x);
+ const qBoundary = qCanvas + Math.abs($topLeft.y - $bottomRight.y);
+
+ const pWidget = widget.box.left;
+ const qWidget = widget.box.top;
+
+ xWidget = pWidget - pCanvas;
+ yWidget = qWidget - qCanvas;
+
+ // Case 1: Boundary jump happens inside the box
+ if (pWidget < pCanvas && pBoundary > maxSize && pWidget < pBoundary - maxSize) {
+ xWidget = xWidget + maxSize;
+ }
+ // Case 2: Boundary jump happens to the left of the box
+ else if (pWidget > pCanvas && pBoundary < maxSize && pWidget > pBoundary) {
+ xWidget = xWidget - maxSize;
+ }
+
+ // Case 1: Boundary jump happens inside the box
+ if (qWidget < qCanvas && qBoundary > maxSize && qWidget < qBoundary - maxSize) {
+ yWidget = yWidget + maxSize;
+ }
+ // Case 2: Boundary jump happens above the top of the box
+ else if (qWidget > qCanvas && qBoundary < maxSize && qWidget > qBoundary) {
+ yWidget = yWidget - maxSize;
+ }
+ }