Skip to content

Commit f4595bc

Browse files
Merge pull request #54 from maerzhase/master
2 parents 4394c80 + a2e72c6 commit f4595bc

File tree

10 files changed

+1393
-7450
lines changed

10 files changed

+1393
-7450
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ These are the props you can set on the `Scrollama` component itself:
137137

138138
| Prop | Type | Default | Description |
139139
|----------------|---------------------------|---------|-----------------------------------------------------------------------------------------|
140-
| offset | `number` (from 0 to 1) | 0.3 | How far from the top of the viewport to trigger a step (as a proportion of view height) |
141-
| progress | `boolean` | false | Whether to fire incremental step progress updates |
140+
| offset | `number` (from 0 to 1) or pixel value (e.g. "300px") | 0.3 | How far from the top of the viewport to trigger a step (as a proportion of view height) |
142141
| threshold | `number` (greater than 1) | 4 | Granularity of the progress interval in pixels (smaller = more granular) |
143142
| onStepEnter | `function` | | Callback that fires when the top or bottom edge of a step enters the offset threshold. |
144143
| onStepExit | `function` | | Callback that fires when the top or bottom edge of a step exits the offset threshold. |
@@ -152,6 +151,7 @@ The `onStepEnter` and `onStepExit` callbacks receive one argument, an object, wi
152151
element, // The DOM node of the step that was triggered
153152
data, // The data supplied to the step
154153
direction, // 'up' or 'down'
154+
entry, // the original `IntersectionObserver` entry
155155
}
156156
```
157157

@@ -162,6 +162,8 @@ The `onStepProgress` callback receives one argument, an object, with the followi
162162
element, // The DOM node of the step that was triggered
163163
data, // The data supplied to the step
164164
progress, // The percent of completion of the step (0 to 1)
165+
direction, // 'up' or 'down'
166+
entry, // the original `IntersectionObserver` entry
165167
}
166168
```
167169

@@ -199,7 +201,6 @@ You will also probably want to set a `key` prop on each `Step` if you're transfo
199201

200202
## Features roadmap
201203

202-
* Being able to use pixels instead of percent for offset value so stuff on mobile doesn't jump around on scroll direction change
203204
* Currently, there is no way to throttle/customize React Scrollama's [resize listener](https://github.com/jsonkao/react-scrollama/blob/master/src/Scrollama.js#L104) 😢. We're working on this in [#44](https://github.com/jsonkao/react-scrollama/issues/44).
204205
* Fire previous step triggers if they were jumped
205206

example/package-lock.json

Lines changed: 902 additions & 907 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"license": "MIT",
77
"dependencies": {
88
"prop-types": "^15.7.2",
9-
"react": "^16.13.1",
10-
"react-dom": "^16.13.1",
9+
"react": "^17.0.1",
10+
"react-dom": "^17.0.1",
1111
"react-jss": "^10.1.1",
1212
"react-scripts": "^3.4.1",
1313
"react-scrollama": "file:../"

example/src/Demo.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ class Demo extends PureComponent {
133133
progress: 0,
134134
};
135135

136-
onStepEnter = ({ data }) => {
136+
onStepEnter = e => {
137+
const { data, entry, direction} = e;
137138
this.setState({ data });
138139
};
139140

@@ -185,7 +186,7 @@ class Demo extends PureComponent {
185186
onStepExit={this.onStepExit}
186187
progress
187188
onStepProgress={this.onStepProgress}
188-
offset={0.5}
189+
offset="350px"
189190
debug
190191
>
191192
{steps.map(value => {

0 commit comments

Comments
 (0)