@@ -120,6 +120,8 @@ import {
120120 xMin,
121121 } = element . offsets ;
122122
123+ const { slowerScrollRate } = element . props ;
124+
123125 // NOTE: Many of these cause layout and reflow so don't
124126 // do this on every frame, instead the values are cached
125127 // to access later
@@ -147,11 +149,11 @@ import {
147149 const xMinPx = xPercent ? ( xMin . value * w100 ) : xMin . value ; // negative value
148150
149151 // NOTE: must add the current scroll position when the
150- // element is checked so that we get it's absolute position
152+ // element is checked so that we get its absolute position
151153 // relative to the document and not the viewport then
152154 // add the min/max offsets calculated above
153- const top = rect . top + scrollY + yMinPx ;
154- const bottom = rect . bottom + scrollY + yMaxPx ;
155+ const top = rect . top + scrollY + ( slowerScrollRate ? yMinPx : yMaxPx * - 1 ) ;
156+ const bottom = rect . bottom + scrollY + ( slowerScrollRate ? yMaxPx : yMinPx * - 1 ) ;
155157
156158 // Total distance the element will move from when
157159 // the top enters the view to the bottom leaving
@@ -192,6 +194,7 @@ import {
192194 const xMin = parseValueAndUnit ( offsetXMax ) ;
193195 const xMax = parseValueAndUnit ( offsetXMin ) ;
194196
197+ // @TODO : Move error to component proptypes
195198 if ( xMin . unit !== xMax . unit || yMin . unit !== yMax . unit ) {
196199 throw new Error ( 'Must provide matching units for the min and max offset values of each axis.' ) ;
197200 }
@@ -216,10 +219,9 @@ import {
216219
217220 const topInView = top >= 0 && top <= windowHeight ;
218221 const bottomInView = bottom >= 0 && bottom <= windowHeight ;
219- const covering = top <= 0 && bottom >= windowHeight ;
222+ const covering = top <= 0 && bottom >= windowHeight ;
220223
221224 const isInView = topInView || bottomInView || covering ;
222-
223225 // console.log('top', topInView, 'bottom', bottomInView, 'covering', covering);
224226
225227 return isInView ;
@@ -232,8 +234,7 @@ import {
232234 totalDist,
233235 } = element . attributes ;
234236
235- // Percent the element has moved based on current and total
236- // distance to move clamped to keep within range 0-100%
237+ // Percent the element has moved based on current and total distance to move
237238 const percentMoved = ( top * - 1 + windowHeight ) / totalDist * 100 ;
238239
239240 // Scale percentMoved to min/max percent determined by offset props
0 commit comments