Skip to content

Commit 71ea875

Browse files
committed
fix: exempt drag group from per-frame culling
1 parent 1b2dd8f commit 71ea875

3 files changed

Lines changed: 26 additions & 3 deletions

File tree

js/activity.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,8 +605,7 @@ class Activity {
605605
if (
606606
this.blocks &&
607607
this.blocksContainer &&
608-
(isInteracting ||
609-
this._lastCullContainerX !== this.blocksContainer.x ||
608+
(this._lastCullContainerX !== this.blocksContainer.x ||
610609
this._lastCullContainerY !== this.blocksContainer.y)
611610
) {
612611
this.blocks._updateViewportCulling();

js/block.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3272,6 +3272,13 @@ class Block {
32723272
// Cache the drag group once on mousedown instead of
32733273
// recomputing the tree traversal on every pressmove.
32743274
that.blocks.cacheDragGroup(thisBlock);
3275+
// Track the drag group for viewport culling exemption during drag,
3276+
// so off-screen stack siblings remain visible while being dragged
3277+
// into view (avoids "pop-in" on release).
3278+
const group = that.blocks._cachedDragGroup;
3279+
if (group && group.length > 0) {
3280+
that.blocks._dragActiveGroup = new Set(group);
3281+
}
32753282
// Invalidate the top-block cache since a drag may
32763283
// disconnect blocks, changing the topology.
32773284
that.blocks.invalidateTopBlockCache();

js/blocks.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,10 @@ class Blocks {
358358
this._checkBoundsScheduled = false;
359359
// Cached drag group computed once on mousedown, reused during pressmove
360360
this._cachedDragGroup = null;
361+
// Blocks in the active drag group are exempt from viewport culling
362+
// during the drag to avoid "pop-in" when off-screen siblings are
363+
// dragged into view. Cleared on pressup/mouseout.
364+
this._dragActiveGroup = null;
361365
// Cached top-block map for moveAllBlocksExcept edge-scroll
362366
this._topBlockCache = null;
363367
// Throttle timestamp for edge-scroll calls
@@ -3555,7 +3559,19 @@ class Blocks {
35553559
// Support viewport culling via _viewportVisible (eye icon takes priority).
35563560
myBlock.container._origIsVisible = myBlock.container.isVisible;
35573561
myBlock.container.isVisible = function () {
3558-
if (!myBlock._viewportVisible) return false;
3562+
if (!myBlock._viewportVisible) {
3563+
// During a drag, show blocks in the active drag group even
3564+
// if they are off-screen, so the user sees the entire stack
3565+
// follow the cursor smoothly instead of "popping in" on release.
3566+
if (
3567+
myBlock.blocks &&
3568+
myBlock.blocks._dragActiveGroup &&
3569+
myBlock.blocks._dragActiveGroup.has(myBlock.blockIndex)
3570+
) {
3571+
return this._origIsVisible.call(this);
3572+
}
3573+
return false;
3574+
}
35593575
return this._origIsVisible.call(this);
35603576
};
35613577

@@ -4036,6 +4052,7 @@ class Blocks {
40364052
*/
40374053
this.clearCachedDragGroup = () => {
40384054
this._cachedDragGroup = null;
4055+
this._dragActiveGroup = null;
40394056
};
40404057

40414058
/**

0 commit comments

Comments
 (0)