UNPKG

higimo-scroll-spy

Version:

Компонент следит за тем, до какого элемента доскроллил клиент и передает сообщение в другой элемент

6 lines 12.1 kB
module.exports=function(t){function e(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,o){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:o})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=1)}([function(t,e){t.exports=require("react")},function(t,e,n){var o=n(2).default;t.exports=o},function(t,e,n){var o=n(0),r=n(3),i=n(10),s=r({getPropTypes:function(){return{name:PropTypes.string,update:PropTypes.function,interval:PropTypes.number,children:PropTypes.oneOfType([PropTypes.element,PropTypes.arrayOf(PropTypes.element)])}},getDefaultProps:function(){return{interval:50,children:null,name:"default",update:()=>{console.warn("standard definition of update")}}},getInitialState:function(){return{visible:!1,throttle:i(this.props.interval,this.isComponentVisible)}},componentDidMount:function(){window.addEventListener("scroll",this.state.throttle),window.addEventListener("resize",this.state.throttle),this.isComponentVisible()},componentWillUnmount:function(){window.removeEventListener("scroll",this.state.throttle),window.removeEventListener("resize",this.state.throttle)},setNodeRef:function(t){this.nodeRef=t},getPropsToRender:function(){var t={};return null!==this.props.className&&(t.className=this.props.className),null!==this.props.style&&(t.style=this.props.style),0!==this.props.offset&&(t.offset=this.props.offset),t},getChildren:function(){return o.Children.map(this.props.children,t=>o.cloneElement(t,{visible:this.state.visible}))},isComponentVisible:function(){var t=this.nodeRef.getBoundingClientRect();this.props.update(this.props.name,t)},render:function(){var t=this.getPropsToRender();return t.ref=this.setNodeRef,o.createElement("div",t,this.getChildren())}});t.exports=s},function(t,e,n){"use strict";var o=n(0),r=n(4);if(void 0===o)throw Error("create-react-class could not find the React object. If you are using script tags, make sure that React is being loaded before create-react-class.");var i=(new o.Component).updater;t.exports=r(o.Component,o.isValidElement,i)},function(t,e,n){"use strict";function o(t){return t}var r,i=n(5),s=n(6),a=n(7),c=n(8),u="mixins";r={prop:"prop",context:"context",childContext:"child context"},t.exports=function(t,e,n){function p(t,e,n){for(var o in e)e.hasOwnProperty(o)&&c("function"==typeof e[o],"%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.",t.displayName||"ReactClass",r[n],o)}function l(t,e){var n=b.hasOwnProperty(e)?b[e]:null;w.hasOwnProperty(e)&&a("OVERRIDE_BASE"===n,"ReactClassInterface: You are attempting to override `%s` from your class specification. Ensure that your method names do not overlap with React methods.",e),t&&a("DEFINE_MANY"===n||"DEFINE_MANY_MERGED"===n,"ReactClassInterface: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.",e)}function f(t,n){if(n){a("function"!=typeof n,"ReactClass: You're attempting to use a component class or function as a mixin. Instead, just use a regular object."),a(!e(n),"ReactClass: You're attempting to use a component as a mixin. Instead, just use a regular object.");var o=t.prototype,r=o.__reactAutoBindPairs;n.hasOwnProperty(u)&&N.mixins(t,n.mixins);for(var i in n)if(n.hasOwnProperty(i)&&i!==u){var s=n[i],p=o.hasOwnProperty(i);if(l(p,i),N.hasOwnProperty(i))N[i](t,s);else{var f=b.hasOwnProperty(i);if("function"!=typeof s||f||p||!1===n.autobind)if(p){var d=b[i];a(f&&("DEFINE_MANY_MERGED"===d||"DEFINE_MANY"===d),"ReactClass: Unexpected spec policy %s for key %s when mixing in component specs.",d,i),"DEFINE_MANY_MERGED"===d?o[i]=m(o[i],s):"DEFINE_MANY"===d&&(o[i]=y(o[i],s))}else o[i]=s,"function"==typeof s&&n.displayName&&(o[i].displayName=n.displayName+"_"+i);else r.push(i,s),o[i]=s}}}else{var h=typeof n;c("object"===h&&null!==n,"%s: You're attempting to include a mixin that is either null or not an object. Check the mixins included by the component, as well as any mixins they include themselves. Expected object but got %s.",t.displayName||"ReactClass",null===n?null:h)}}function d(t,e){if(e)for(var n in e){var o=e[n];e.hasOwnProperty(n)&&(a(!(n in N),'ReactClass: You are attempting to define a reserved property, `%s`, that shouldn\'t be on the "statics" key. Define it as an instance property instead; it will still be accessible on the constructor.',n),a(!(n in t),"ReactClass: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.",n),t[n]=o)}}function h(t,e){a(t&&e&&"object"==typeof t&&"object"==typeof e,"mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.");for(var n in e)e.hasOwnProperty(n)&&(a(void 0===t[n],"mergeIntoWithNoDuplicateKeys(): Tried to merge two objects with the same key: `%s`. This conflict may be due to a mixin; in particular, this may be caused by two getInitialState() or getDefaultProps() methods returning objects with clashing keys.",n),t[n]=e[n]);return t}function m(t,e){return function(){var n=t.apply(this,arguments),o=e.apply(this,arguments);if(null==n)return o;if(null==o)return n;var r={};return h(r,n),h(r,o),r}}function y(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function v(t,e){var n=e.bind(t);n.__reactBoundContext=t,n.__reactBoundMethod=e,n.__reactBoundArguments=null;var o=t.constructor.displayName,r=n.bind;return n.bind=function(i){for(var s=arguments.length,a=Array(s>1?s-1:0),u=1;u<s;u++)a[u-1]=arguments[u];if(i!==t&&null!==i)c(!1,"bind(): React component methods may only be bound to the component instance. See %s",o);else if(!a.length)return c(!1,"bind(): You are binding a component method to the component. React does this for you automatically in a high-performance way, so you can safely remove this call. See %s",o),n;var p=r.apply(n,arguments);return p.__reactBoundContext=t,p.__reactBoundMethod=e,p.__reactBoundArguments=a,p},n}function g(t){for(var e=t.__reactAutoBindPairs,n=0;n<e.length;n+=2){var o=e[n],r=e[n+1];t[o]=v(t,r)}}var E=[],b={mixins:"DEFINE_MANY",statics:"DEFINE_MANY",propTypes:"DEFINE_MANY",contextTypes:"DEFINE_MANY",childContextTypes:"DEFINE_MANY",getDefaultProps:"DEFINE_MANY_MERGED",getInitialState:"DEFINE_MANY_MERGED",getChildContext:"DEFINE_MANY_MERGED",render:"DEFINE_ONCE",componentWillMount:"DEFINE_MANY",componentDidMount:"DEFINE_MANY",componentWillReceiveProps:"DEFINE_MANY",shouldComponentUpdate:"DEFINE_ONCE",componentWillUpdate:"DEFINE_MANY",componentDidUpdate:"DEFINE_MANY",componentWillUnmount:"DEFINE_MANY",updateComponent:"OVERRIDE_BASE"},N={displayName:function(t,e){t.displayName=e},mixins:function(t,e){if(e)for(var n=0;n<e.length;n++)f(t,e[n])},childContextTypes:function(t,e){p(t,e,"childContext"),t.childContextTypes=i({},t.childContextTypes,e)},contextTypes:function(t,e){p(t,e,"context"),t.contextTypes=i({},t.contextTypes,e)},getDefaultProps:function(t,e){t.getDefaultProps?t.getDefaultProps=m(t.getDefaultProps,e):t.getDefaultProps=e},propTypes:function(t,e){p(t,e,"prop"),t.propTypes=i({},t.propTypes,e)},statics:function(t,e){d(t,e)},autobind:function(){}},_={componentDidMount:function(){this.__isMounted=!0}},x={componentWillUnmount:function(){this.__isMounted=!1}},w={replaceState:function(t,e){this.updater.enqueueReplaceState(this,t,e)},isMounted:function(){return c(this.__didWarnIsMounted,"%s: isMounted is deprecated. Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks.",this.constructor&&this.constructor.displayName||this.name||"Component"),this.__didWarnIsMounted=!0,!!this.__isMounted}},D=function(){};return i(D.prototype,t.prototype,w),function(t){var e=o(function(t,o,r){c(this instanceof e,"Something is calling a React component directly. Use a factory or JSX instead. See: https://fb.me/react-legacyfactory"),this.__reactAutoBindPairs.length&&g(this),this.props=t,this.context=o,this.refs=s,this.updater=r||n,this.state=null;var i=this.getInitialState?this.getInitialState():null;void 0===i&&this.getInitialState._isMockFunction&&(i=null),a("object"==typeof i&&!Array.isArray(i),"%s.getInitialState(): must return an object or null",e.displayName||"ReactCompositeComponent"),this.state=i});e.prototype=new D,e.prototype.constructor=e,e.prototype.__reactAutoBindPairs=[],E.forEach(f.bind(null,e)),f(e,_),f(e,t),f(e,x),e.getDefaultProps&&(e.defaultProps=e.getDefaultProps()),e.getDefaultProps&&(e.getDefaultProps.isReactClassApproved={}),e.prototype.getInitialState&&(e.prototype.getInitialState.isReactClassApproved={}),a(e.prototype.render,"createClass(...): Class specification must implement a `render` method."),c(!e.prototype.componentShouldUpdate,"%s has a method called componentShouldUpdate(). Did you mean shouldComponentUpdate()? The name is phrased as a question because the function is expected to return a value.",t.displayName||"A component"),c(!e.prototype.componentWillRecieveProps,"%s has a method called componentWillRecieveProps(). Did you mean componentWillReceiveProps()?",t.displayName||"A component");for(var r in b)e.prototype[r]||(e.prototype[r]=null);return e}}},function(t,e,n){"use strict";function o(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}/* object-assign (c) Sindre Sorhus @license MIT */ var r=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;t.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},n=0;n<10;n++)e["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(e).map(function(t){return e[t]}).join(""))return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(t){o[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},o)).join("")}catch(t){return!1}}()?Object.assign:function(t,e){for(var n,a,c=o(t),u=1;u<arguments.length;u++){n=Object(arguments[u]);for(var p in n)i.call(n,p)&&(c[p]=n[p]);if(r){a=r(n);for(var l=0;l<a.length;l++)s.call(n,a[l])&&(c[a[l]]=n[a[l]])}}return c}},function(t,e,n){"use strict";var o={};Object.freeze(o),t.exports=o},function(t,e,n){"use strict";var o=function(t){};o=function(t){if(void 0===t)throw new Error("invariant requires an error message argument")},t.exports=function(t,e,n,r,i,s,a,c){if(o(e),!t){var u;if(void 0===e)u=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var p=[n,r,i,s,a,c],l=0;(u=new Error(e.replace(/%s/g,function(){return p[l++]}))).name="Invariant Violation"}throw u.framesToPop=1,u}}},function(t,e,n){"use strict";var o=n(9),r=function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),o=1;o<e;o++)n[o-1]=arguments[o];var r=0,i="Warning: "+t.replace(/%s/g,function(){return n[r++]});"undefined"!=typeof console&&console.error(i);try{throw new Error(i)}catch(t){}};o=function(t,e){if(void 0===e)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(0!==e.indexOf("Failed Composite propType: ")&&!t){for(var n=arguments.length,o=Array(n>2?n-2:0),i=2;i<n;i++)o[i-2]=arguments[i];r.apply(void 0,[e].concat(o))}},t.exports=o},function(t,e,n){"use strict";function o(t){return function(){return t}}var r=function(){};r.thatReturns=o,r.thatReturnsFalse=o(!1),r.thatReturnsTrue=o(!0),r.thatReturnsNull=o(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(t){return t},t.exports=r},function(t,e,n){var o=n(11);t.exports=function(t,e,n){return void 0===n?o(t,e,!1):o(t,n,!1!==e)}},function(t,e){t.exports=function(t,e,n,o){var r,i=0;return"boolean"!=typeof e&&(o=n,n=e,e=void 0),function(){function s(){i=Number(new Date),n.apply(a,u)}var a=this,c=Number(new Date)-i,u=arguments;o&&!r&&s(),r&&clearTimeout(r),void 0===o&&c>t?s():!0!==e&&(r=setTimeout(o?function(){r=void 0}:s,void 0===o?t-c:t))}}}]);