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

adjust bottom viewability math #2

Closed
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"**/node_modules": true
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"eslint.validate": ["typescript", "typescriptreact"],
"editor.formatOnSave": true,
Expand Down
8 changes: 4 additions & 4 deletions src/viewability/ViewabilityHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@
if (itemLayout === undefined) {
return false;
}
const itemTop = (horizontal ? itemLayout.x : itemLayout.y) - scrollOffset;
const itemTop = (horizontal ? itemLayout.x : itemLayout.y) - scrollOffset + bottomViewabilityInset;

Check failure on line 137 in src/viewability/ViewabilityHelper.ts

View workflow job for this annotation

GitHub Actions / Lint Typescript

Replace `·(horizontal·?·itemLayout.x·:·itemLayout.y)·-·scrollOffset·+` with `⏎······(horizontal·?·itemLayout.x·:·itemLayout.y)·-⏎······scrollOffset·+⏎·····`
const itemSize = horizontal ? itemLayout.width : itemLayout.height;
const listMainSize = horizontal
? listSize.width
: listSize.height - bottomViewabilityInset;
const listMainSize = horizontal ? listSize.width : listSize.height;
const pixelsVisible =
Math.min(itemTop + itemSize, listMainSize) - Math.max(itemTop, 0);

console.log(`pikachu isItemViewable. index: ${index}, itemTop: ${itemTop}, itemSize: ${itemSize}, listMainSize: ${listMainSize}, pixelsVisible: ${pixelsVisible}. scrollOffset: ${scrollOffset}. bottomViewabilityInset: ${bottomViewabilityInset}`)

Check failure on line 143 in src/viewability/ViewabilityHelper.ts

View workflow job for this annotation

GitHub Actions / Lint Typescript

This line has a length of 248. Maximum allowed is 200

Check failure on line 143 in src/viewability/ViewabilityHelper.ts

View workflow job for this annotation

GitHub Actions / Lint Typescript

Replace ``pikachu·isItemViewable.·index:·${index},·itemTop:·${itemTop},·itemSize:·${itemSize},·listMainSize:·${listMainSize},·pixelsVisible:·${pixelsVisible}.·scrollOffset:·${scrollOffset}.·bottomViewabilityInset:·${bottomViewabilityInset}`)` with `⏎······`pikachu·isItemViewable.·index:·${index},·itemTop:·${itemTop},·itemSize:·${itemSize},·listMainSize:·${listMainSize},·pixelsVisible:·${pixelsVisible}.·scrollOffset:·${scrollOffset}.·bottomViewabilityInset:·${bottomViewabilityInset}`⏎····);`

// Always consider item fully viewable if it is fully visible, regardless of the `viewAreaCoveragePercentThreshold`
// Account for floating point imprecision.
if (Math.abs(pixelsVisible - itemSize) <= 0.001) {
Expand Down
Loading