Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
Fix max pixel scroll float issue that prevents some data from hitting…
Browse files Browse the repository at this point in the history
… table (#102)

* uses Math.trunc on maxPixelScrollDepth

* adds comment

* updates version number
  • Loading branch information
hamilton authored Apr 22, 2021
1 parent 89a1116 commit c066eee
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"author": "Mozilla Rally",
"manifest_version": 2,
"name": "Your Time Online and \"Doomscrolling\"",
"version": "0.1.4",
"version": "0.1.5",
"homepage_url": "https://github.com/mozilla-rally/rally-study-01",

"icons": {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rally-study-01",
"version": "0.1.4",
"version": "0.1.5",
"scripts": {
"build": "npm run build:schema && rollup -c",
"build:addon": "rollup -c && web-ext build --overwrite-dest",
Expand Down
11 changes: 8 additions & 3 deletions src/content-scripts/attention-collector.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,15 @@

scrollHeight = document.documentElement.scrollHeight;

// We accidentally let the schema type for this be `integer` so
// we will have to truncate, since on occasion this reports a float.
maxPixelScrollDepth =
Math.min(scrollHeight,
Math.max(maxPixelScrollDepth, window.scrollY + document.documentElement.clientHeight)
);
Math.trunc(
Math.min(scrollHeight,
Math.max(maxPixelScrollDepth, window.scrollY + document.documentElement.clientHeight)
)
);

maxRelativeScrollDepth = Math.min(
Math.max(maxRelativeScrollDepth, (window.scrollY + document.documentElement.clientHeight) / scrollHeight),
1);
Expand Down

0 comments on commit c066eee

Please sign in to comment.