Comparing version 0.0.4 to 0.0.5
@@ -73,2 +73,4 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -101,3 +103,8 @@ | ||
var loading = _state.loading; | ||
var _props = this.props; | ||
var offsetRatio = _props.offsetRatio; | ||
var onNewData = _props.onNewData; | ||
var rest = _objectWithoutProperties(_props, ['offsetRatio', 'onNewData']); | ||
var enabled = !disabled && !loading; // not listening for onScroll event | ||
@@ -107,3 +114,3 @@ // if disabled or loading | ||
'div', | ||
_extends({}, this.props, { onScroll: enabled && this.handleScroll.bind(this) }), | ||
_extends({}, rest, { onScroll: enabled && this.handleScroll.bind(this) }), | ||
this.props.children | ||
@@ -115,5 +122,5 @@ ); | ||
value: function handleScroll(e) { | ||
var _props = this.props; | ||
var offsetRatio = _props.offsetRatio; | ||
var onNewData = _props.onNewData; | ||
var _props2 = this.props; | ||
var offsetRatio = _props2.offsetRatio; | ||
var onNewData = _props2.onNewData; | ||
var target = e.target; | ||
@@ -120,0 +127,0 @@ |
@@ -1,1 +0,1 @@ | ||
!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.React8=t(require("react")):e.React8=t(e.React)}(this,function(e){return function(e){function t(o){if(r[o])return r[o].exports;var n=r[o]={exports:{},id:o,loaded:!1};return e[o].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(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 i(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)}var s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e},u=function(){function e(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}}();Object.defineProperty(t,"__esModule",{value:!0});var l=r(1),c=o(l),f=function(e){function t(e){n(this,t);var r=a(this,Object.getPrototypeOf(t).call(this,e));return r.state={disabled:!1,loading:!1},r}return i(t,e),u(t,[{key:"render",value:function(){var e=this.state,t=e.disabled,r=e.loading,o=!t&&!r;return c["default"].createElement("div",s({},this.props,{onScroll:o&&this.handleScroll.bind(this)}),this.props.children)}},{key:"handleScroll",value:function(e){var t=this.props,r=t.offsetRatio,o=t.onNewData,n=e.target,a=n.scrollHeight,i=n.offsetHeight,s=n.scrollTop,u=i+s;u>=a-i*r&&o&&(1===o.length?(this.setState({loading:!0}),o(this.newDataCallback.bind(this))):o()===!1&&this.setState({disabled:!0}))}},{key:"newDataCallback",value:function(e){e===!1&&this.setState({disabled:!0}),this.setState({loading:!1})}}]),t}(c["default"].Component);t["default"]=f,f.defaultProps={offsetRatio:.5},f.propTypes={offsetRatio:l.PropTypes.number.isRequired,onNewData:l.PropTypes.func.isRequired}},function(t,r){t.exports=e}])}); | ||
!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.React8=t(require("react")):e.React8=t(e.React)}(this,function(e){return function(e){function t(r){if(o[r])return o[r].exports;var n=o[r]={exports:{},id:r,loaded:!1};return e[r].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var o={};return t.m=e,t.c=o,t.p="",t(0)}([function(e,t,o){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function n(e,t){var o={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(o[r]=e[r]);return o}function a(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 s(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)}var u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},f=function(){function e(e,t){for(var o=0;o<t.length;o++){var r=t[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,o,r){return o&&e(t.prototype,o),r&&e(t,r),t}}();Object.defineProperty(t,"__esModule",{value:!0});var l=o(1),c=r(l),p=function(e){function t(e){a(this,t);var o=i(this,Object.getPrototypeOf(t).call(this,e));return o.state={disabled:!1,loading:!1},o}return s(t,e),f(t,[{key:"render",value:function(){var e=this.state,t=e.disabled,o=e.loading,r=this.props,a=(r.offsetRatio,r.onNewData,n(r,["offsetRatio","onNewData"])),i=!t&&!o;return c["default"].createElement("div",u({},a,{onScroll:i&&this.handleScroll.bind(this)}),this.props.children)}},{key:"handleScroll",value:function(e){var t=this.props,o=t.offsetRatio,r=t.onNewData,n=e.target,a=n.scrollHeight,i=n.offsetHeight,s=n.scrollTop,u=i+s;u>=a-i*o&&r&&(1===r.length?(this.setState({loading:!0}),r(this.newDataCallback.bind(this))):r()===!1&&this.setState({disabled:!0}))}},{key:"newDataCallback",value:function(e){e===!1&&this.setState({disabled:!0}),this.setState({loading:!1})}}]),t}(c["default"].Component);t["default"]=p,p.defaultProps={offsetRatio:.5},p.propTypes={offsetRatio:l.PropTypes.number.isRequired,onNewData:l.PropTypes.func.isRequired}},function(t,o){t.exports=e}])}); |
{ | ||
"name": "react-8", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Simple infinite scrolling for React", | ||
@@ -35,2 +35,3 @@ "main": "build/react-8.js", | ||
"babel-preset-react": "^6.3.13", | ||
"babel-preset-stage-2": "^6.13.0", | ||
"chai": "^3.4.1", | ||
@@ -37,0 +38,0 @@ "chai-spies": "^0.7.1", |
@@ -13,6 +13,7 @@ import React, {PropTypes} from 'react'; | ||
const {disabled, loading} = this.state; | ||
const {offsetRatio, onNewData, ...rest} = this.props; | ||
const enabled = !disabled && !loading; // not listening for onScroll event | ||
// if disabled or loading | ||
return ( | ||
<div {...this.props} onScroll={enabled && this.handleScroll.bind(this)}> | ||
<div {...rest} onScroll={enabled && this.handleScroll.bind(this)}> | ||
{this.props.children} | ||
@@ -19,0 +20,0 @@ </div> |
@@ -30,3 +30,3 @@ const path = require('path'); | ||
query: { | ||
presets: ['react', 'es2015'] | ||
presets: ['react', 'es2015', 'stage-2'] | ||
} | ||
@@ -33,0 +33,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25131
446
14