Skip to content

Commit 35323f4

Browse files
committed
renames count state property to eventsFired
1 parent 17ba2c3 commit 35323f4

File tree

4 files changed

+14
-28
lines changed

4 files changed

+14
-28
lines changed

demo/ScrollInfo.demo.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ const ScrollInfoDemo = (props) => {
1414
xPercentage,
1515
yPercentage,
1616
totalPercentage,
17-
count,
17+
eventsFired,
1818
},
1919
} = props;
2020

2121
return (
2222
<div style={{ position: 'fixed' }}>
2323
<code>
2424
<pre>
25-
{'scrollPos:{'}
25+
{'scrollInfo: {'}
2626
<br />
2727
&emsp;
2828
{`x: ${x},`}
@@ -52,7 +52,7 @@ const ScrollInfoDemo = (props) => {
5252
{`totalPercentage: ${totalPercentage}`}
5353
<br />
5454
&emsp;
55-
{`count: ${count},`}
55+
{`eventsFired: ${eventsFired},`}
5656
<br />
5757
{'}'}
5858
</pre>
@@ -80,7 +80,7 @@ ScrollInfoDemo.propTypes = {
8080
xPercentage: PropTypes.number,
8181
yPercentage: PropTypes.number,
8282
totalPercentage: PropTypes.number,
83-
count: PropTypes.number,
83+
eventsFired: PropTypes.number,
8484
}).isRequired,
8585
};
8686

dist/build.bundle.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@trbl/react-scroll-info",
3-
"version": "0.0.12",
3+
"version": "0.0.13",
44
"main": "dist/build.bundle.js",
55
"repository": "git@github.com:trouble/react-scroll-info.git",
66
"description": "A roll, as of parchment or papyrus, used especially in the writing of a document.",

src/ScrollInfoProvider/index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class ScrollInfoProvider extends Component {
1717
xPercentage: 0,
1818
yPercentage: 0,
1919
totalPercentage: 0,
20-
count: 0,
2120
eventsFired: 0,
21+
animationsFired: 0,
2222
};
2323
}
2424

@@ -35,16 +35,16 @@ class ScrollInfoProvider extends Component {
3535
const {
3636
x: lastScrollX,
3737
y: lastScrollY,
38-
count: scrollCount,
3938
eventsFired,
39+
animationsFired,
4040
} = this.state;
4141

4242
// Set to zero on first iteration for cross-browser compatibility
4343
// The inconsistencies occur when the window is reloaded with a cached scroll position
4444
// Chrome mounts with the cached window.pageOffset
4545
// Safari and FireFox don't populate it until the first scroll event which is triggered by the browser
46-
const currentScrollX = eventsFired > 0 ? window.pageXOffset : 0;
47-
const currentScrollY = eventsFired > 0 ? window.pageYOffset : 0;
46+
const currentScrollX = animationsFired > 0 ? window.pageXOffset : 0;
47+
const currentScrollY = animationsFired > 0 ? window.pageYOffset : 0;
4848

4949
const xDifference = currentScrollX - lastScrollX;
5050
const yDifference = currentScrollY - lastScrollY;
@@ -65,15 +65,15 @@ class ScrollInfoProvider extends Component {
6565
xPercentage,
6666
yPercentage,
6767
totalPercentage,
68-
count: scrollHasChanged ? scrollCount + 1 : scrollCount,
68+
eventsFired: scrollHasChanged ? eventsFired + 1 : eventsFired,
6969
});
7070
};
7171

7272
requestAnimation = () => {
73-
const { animationScheduled, eventsFired } = this.state;
73+
const { animationScheduled, animationsFired } = this.state;
7474
if (!animationScheduled) {
7575
requestAnimationFrame(this.updateScrollInfo);
76-
this.setState({ animationScheduled: true, eventsFired: eventsFired + 1 });
76+
this.setState({ animationScheduled: true, animationsFired: animationsFired + 1 });
7777
}
7878
}
7979

@@ -89,7 +89,7 @@ class ScrollInfoProvider extends Component {
8989
xPercentage,
9090
yPercentage,
9191
totalPercentage,
92-
count,
92+
eventsFired,
9393
} = this.state;
9494

9595
return (
@@ -105,7 +105,7 @@ class ScrollInfoProvider extends Component {
105105
xPercentage,
106106
yPercentage,
107107
totalPercentage,
108-
count,
108+
eventsFired,
109109
},
110110
}}
111111
>

0 commit comments

Comments
 (0)