UNPKG

react-scroll-listen

Version:
1 lines 3.29 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactScrollListen=t(require("react")):e.ReactScrollListen=t(e.React)}(this,function(e){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="dist/",t(t.s=4)}([function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){(function(t){var o,r=void 0!==t?t:"undefined"!=typeof window?window:{},i=n(5);"undefined"!=typeof document?o=document:(o=r["__GLOBAL_DOCUMENT_CACHE@4"])||(o=r["__GLOBAL_DOCUMENT_CACHE@4"]=i),e.exports=o}).call(t,n(0))},function(e,t,n){(function(t){var n;n="undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:{},e.exports=n}).call(t,n(0))},function(t,n){t.exports=e},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),l=n(3),f=(o(l),n(2)),a=o(f),s=n(1),p=o(s),d=function(e){function t(){var e,n,o,c;r(this,t);for(var u=arguments.length,l=Array(u),f=0;f<u;f++)l[f]=arguments[f];return n=o=i(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(l))),o.state={scroll:0,element:o.props.element||p.default.body,container:o.props.container||a.default},o.recordPosition=function(e){var t=o.props.onScroll,n=void 0;n=p.default.scrollingElement?p.default.scrollingElement.scrollTop:e.target===p.default?e.target.body.scrollTop:e.target.scrollTop,t(n,e),o.setState({scroll:n})},c=n,i(o,c)}return c(t,e),u(t,[{key:"componentDidMount",value:function(){var e=this.state,t=e.element,n=e.container;this.setState({scroll:t.scrollTop}),n.addEventListener("scroll",this.recordPosition)}},{key:"componentWillUnmount",value:function(){this.state.container.removeEventListener("scroll",this.recordPosition)}},{key:"render",value:function(){return null}}]),t}(l.PureComponent);t.default=d},function(e,t){}])});