Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jalal246 committed Nov 3, 2023
1 parent 8e8cd63 commit 3601461
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DFlexParentContainer {
private _boundariesByRow: BoxNum;

/** Strict Rect for siblings containers. */
private _siblingBoundaries: BoxNum | null;
private _siblingBoundaries: BoxRect | null;

private _rect: BoxRect;

Expand Down Expand Up @@ -102,7 +102,7 @@ class DFlexParentContainer {
if (this._siblingBoundaries) {
this._siblingBoundaries.assignBiggestBox(rect);
} else {
this._siblingBoundaries = new BoxNum(
this._siblingBoundaries = new BoxRect(
rect.top,
rect.right,
rect.bottom,
Expand Down Expand Up @@ -155,8 +155,8 @@ class DFlexParentContainer {
*
* @returns
*/
getBoundaries(): AbstractBox<number> {
return this._siblingBoundaries || this._rect.getBox();
getBoundaries(): BoxRect {
return this._siblingBoundaries || this._rect;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,8 @@ class DFlexScrollContainer {
this._initializeOrDestroyThreshold("inner", null);
this._initializeOrDestroyThreshold("inner", INNER_THRESHOLD);

if (this.hasDynamicVisibility()) {
this._initializeOrDestroyThreshold("outer", null);
this._initializeOrDestroyThreshold("outer", OUTER_THRESHOLD);
}
this._initializeOrDestroyThreshold("outer", null);
this._initializeOrDestroyThreshold("outer", OUTER_THRESHOLD);
}

private _updateOverflow(): void {
Expand Down
78 changes: 48 additions & 30 deletions packages/dflex-dnd/src/Mechanism/DFlexMechanismController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -868,48 +868,66 @@ class DFlexMechanismController extends DFlexScrollableElement {
private _processScroll(x: number, y: number, SK: string): boolean {
let isOutSiblingsContainer = false;

const { scroll } = this.draggable;
const {
scroll: { enable },
} = this.draggable;

if (scroll.enable) {
this.scrollFeed(x, y, SK);
// If scrolling is disable, do nothing.
if (!enable) {
return false;
}

if (this.hasActiveScrolling()) {
if (!this.hasBeenScrolling) {
scheduler(store, null, {
onUpdate: () => {
isOutSiblingsContainer = this.draggable.isOutThreshold(SK);
const { containers, scrolls } = store;

// When it's inside the container, then the siblings are not lifted
if (!(isOutSiblingsContainer || this.isParentLocked)) {
this._updateContainerLockState(true);
this._fillHeadUp();
}
},
});
const container = containers.get(SK)!;
const scroll = scrolls.get(SK)!;

this.hasBeenScrolling = true;
}
const viewportRect = container.getBoundaries();

return true;
}
const [isInvisible] = scroll.isElmOutViewport(viewportRect, true);

if (this.hasBeenScrolling) {
isOutSiblingsContainer = this.draggable.isOutThreshold(SK);
// If rect is entirely visible, do nothing.
if (!isInvisible) {
return false;
}

if (!isOutSiblingsContainer && this.isParentLocked) {
const [scrollOffsetX, scrollOffsetY] =
this._calculateScrollOffsets(SK);
this.scrollFeed(x, y, SK);

// Update the position before calling the detector.
this.draggable.positions.setPos(x, y, scrollOffsetX, scrollOffsetY);
if (this.hasActiveScrolling()) {
if (!this.hasBeenScrolling) {
scheduler(store, null, {
onUpdate: () => {
isOutSiblingsContainer = this.draggable.isOutThreshold(SK);

this._detectNearestElm();
}
// When it's inside the container, then the siblings are not lifted
if (!(isOutSiblingsContainer || this.isParentLocked)) {
this._updateContainerLockState(true);
this._fillHeadUp();
}
},
});

this.hasBeenScrolling = false;
this.hasBeenScrolling = true;
}

return true;
return true;
}

if (this.hasBeenScrolling) {
isOutSiblingsContainer = this.draggable.isOutThreshold(SK);

if (!isOutSiblingsContainer && this.isParentLocked) {
const [scrollOffsetX, scrollOffsetY] = this._calculateScrollOffsets(SK);

// Update the position before calling the detector.
this.draggable.positions.setPos(x, y, scrollOffsetX, scrollOffsetY);

this._detectNearestElm();
}

this.hasBeenScrolling = false;

return true;
}

return false;
Expand Down

0 comments on commit 3601461

Please sign in to comment.