- xWidget = pWidget - pCanvas;
- yWidget = qWidget - qCanvas;
-
- if (pWidget < pCanvas &&
- pWidget < pBoundary) {
- xWidget = modulo(xWidget, maxSize);
- }
-
- if (qWidget < qCanvas &&
- qWidget < qBoundary) {
- yWidget = modulo(yWidget, maxSize);
- }
-
- console.log('Max', maxSize,
- 'Widget Actual', widget.box.left, widget.box.top,
- 'Top Left', $topLeft.x, $topLeft.y,
- 'Mod Top Left', modulo($topLeft.x, maxSize), modulo($topLeft.y, maxSize),
- 'Calculated',
- modulo(widget.box.left - modulo($topLeft.x, maxSize), maxSize),
- modulo(widget.box.top - modulo($topLeft.y, maxSize), maxSize))
-
- }
+ // 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;
+ }