gilbox / react-spark-scroll

Scroll-based actions and animations for react
358 stars 48 forks source link

Custom formula containerRect attributes #21

Closed t47io closed 7 years ago

t47io commented 7 years ago

I was trying out the custom extensions from README:

var sparkScroll = require('react-spark-scroll/spark-scroll-rekapi')({
  invalidateAutomatically: true
  formulas: {

    //similar to the built-in topBottom formula, except that offset
    // is calculated as a percentage of the viewport height

    topBottomPct: (element, container, rect, containerRect, offset) =>
      ~~(rect.bottom - containerRect.top + offset*containerRect.clientHeight/100)
  }
});

In my testing, the containerRect does not have clientHeight attribute. It should be rather height. Please confirm, and if so, update the Docs. Thanks!

p.s. Also cannot resolve require('react-spark-scroll/spark-scroll-rekapi') in webpack. Used require('react-spark-scroll-rekapi') instead.

t47io commented 7 years ago

Or container.clientHeight?