Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Now rounding window and item bounds. #104

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/core/ViewabilityTracker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import round from "lodash-es/round";
import BinarySearch from "../utils/BinarySearch";
import { Dimension } from "./dependencies/LayoutProvider";
import { Rect } from "./layoutmanager/LayoutManager";

/***
* Given an offset this utility can compute visible items. Also tracks previously visible items to compute items which get hidden or visible
* Virtual renderer uses callbacks from this utility to main recycle pool and the render stack.
Expand Down Expand Up @@ -231,11 +233,11 @@ export default class ViewabilityTracker {

private _setRelevantBounds(itemRect: Rect, relevantDim: Range): void {
if (this._isHorizontal) {
relevantDim.end = itemRect.x + itemRect.width;
relevantDim.start = itemRect.x;
relevantDim.end = round(itemRect.x + itemRect.width);
relevantDim.start = round(itemRect.x);
} else {
relevantDim.end = itemRect.y + itemRect.height;
relevantDim.start = itemRect.y;
relevantDim.end = round(itemRect.y + itemRect.height);
relevantDim.start = round(itemRect.y);
}
}

Expand Down Expand Up @@ -265,8 +267,8 @@ export default class ViewabilityTracker {
this._engagedWindow.start = Math.max(0, newOffset - this._renderAheadOffset);
this._engagedWindow.end = newOffset + this._windowBound + this._renderAheadOffset;

this._visibleWindow.start = newOffset;
this._visibleWindow.end = newOffset + this._windowBound;
this._visibleWindow.start = round(newOffset);
this._visibleWindow.end = round(newOffset + this._windowBound);
}

//TODO:Talha optimize this
Expand Down