Skip to content

Fixed can't work if this component is used in sub container. #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Replace jQuery.extend with a plain javascript one to avoid 'jQuery.ex…
…tend is not a function.'
  • Loading branch information
malikid committed May 26, 2017
commit 3a9429100d6ec78854bd3358421bc73a268d826c
47 changes: 37 additions & 10 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@ Object.defineProperty(exports, "__esModule", {
value: true
});

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /**
* 在页面滚动的时候,监听滚动事件,在快要到达底部指定距离的时候,执行相应函数
* 如果传入 totalPages, 则会在鼠标滚动时
*
* <ReactScrollPagination
fetchFunc = {targetFuc}
totalPages = {totalPages}
/>
*/

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var jQuery = require('jquery'); /**
* 在页面滚动的时候,监听滚动事件,在快要到达底部指定距离的时候,执行相应函数
* 如果传入 totalPages, 则会在鼠标滚动时
*
* <ReactScrollPagination
fetchFunc = {targetFuc}
totalPages = {totalPages}
/>
*/
var jQuery = require('jquery');

var ReactScrollPagination = _react2.default.createClass({
displayName: 'ReactScrollPagination',
Expand Down Expand Up @@ -195,13 +197,38 @@ var ReactScrollPagination = _react2.default.createClass({
jQuery(window).scroll(this.scrollHandler);
},

extend: function (_extend) {
function extend() {
return _extend.apply(this, arguments);
}

extend.toString = function () {
return _extend.toString();
};

return extend;
}(function () {
for (var i = 1; i < arguments.length; i++) {
for (var key in arguments[i]) {
if (arguments[i].hasOwnProperty(key)) {
if (_typeof(arguments[0][key]) === 'object' && _typeof(arguments[i][key]) === 'object') {
extend(arguments[0][key], arguments[i][key]);
} else {
arguments[0][key] = arguments[i][key];
}
}
}
}
return arguments[0];
}),

render: function render() {
// if no totalPages presented, will only do the fetchings
if (typeof this.props.totalPages === 'undefined') {
return null;
}

var acutalPageContentDivStyle = jQuery.extend({}, this.props.innerDivStyle || this.pageContentStyle);
var acutalPageContentDivStyle = this.extend({}, this.props.innerDivStyle || this.pageContentStyle);

// always set the opacity for inner div, so they are able to make the transition
if (!this.state.showPageStatus) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"babel-preset-react": "^6.5.0",
"eslint": "^2.8.0",
"eslint-plugin-flow-vars": "^0.3.0",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"jest-cli": "*",
"jscs": "^3.0.3",
Expand Down
17 changes: 16 additions & 1 deletion src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,28 @@ const ReactScrollPagination = React.createClass({
jQuery(window).scroll(this.scrollHandler)
},

extend: function () {
for(var i = 1; i < arguments.length; i++) {
for(var key in arguments[i]) {
if(arguments[i].hasOwnProperty(key)) {
if (typeof arguments[0][key] === 'object' && typeof arguments[i][key] === 'object') {
extend(arguments[0][key], arguments[i][key])
} else {
arguments[0][key] = arguments[i][key]
}
}
}
}
return arguments[0]
},

render: function () {
// if no totalPages presented, will only do the fetchings
if (typeof this.props.totalPages === 'undefined') {
return (null)
}

let acutalPageContentDivStyle = jQuery.extend({}, this.props.innerDivStyle || this.pageContentStyle)
let acutalPageContentDivStyle = this.extend({}, this.props.innerDivStyle || this.pageContentStyle)

// always set the opacity for inner div, so they are able to make the transition
if (!this.state.showPageStatus) {
Expand Down