Skip to content

Commit 55c822d

Browse files
committedDec 5, 2019
rename package
1 parent 09f698e commit 55c822d

File tree

4 files changed

+115
-91
lines changed

4 files changed

+115
-91
lines changed
 

‎README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# react-scroll-bound
22

3-
prevent scrolling on parent element if list reach end or start
3+
Prevent scrolling on parent element if list reached end or start.
4+
45
Brings a better control for user and increase use experience.
56

67
**[Watch Demo](https://fluse.github.io/react-scroll-bound/)**

‎dist/listScrollBound.js

-82
This file was deleted.

‎dist/scrollBound.js

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
"use strict";
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
exports["default"] = void 0;
7+
8+
var _react = _interopRequireWildcard(require("react"));
9+
10+
var _propTypes = _interopRequireDefault(require("prop-types"));
11+
12+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13+
14+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
15+
16+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17+
18+
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
19+
20+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
21+
22+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
23+
24+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
25+
26+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
27+
28+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
29+
30+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
31+
32+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
33+
34+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
35+
36+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
37+
38+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
39+
40+
var ListScrollBound =
41+
/*#__PURE__*/
42+
function (_Component) {
43+
_inherits(ListScrollBound, _Component);
44+
45+
function ListScrollBound() {
46+
_classCallCheck(this, ListScrollBound);
47+
48+
return _possibleConstructorReturn(this, _getPrototypeOf(ListScrollBound).apply(this, arguments));
49+
}
50+
51+
_createClass(ListScrollBound, [{
52+
key: "componentDidMount",
53+
value: function componentDidMount() {
54+
this.scroller.addEventListener('wheel', this.onWheel.bind(this));
55+
}
56+
}, {
57+
key: "componentWillUnmount",
58+
value: function componentWillUnmount() {
59+
this.scroller.removeEventListener('wheel', this.onWheel.bind(this));
60+
}
61+
}, {
62+
key: "onWheel",
63+
value: function onWheel(e) {
64+
var el = e.currentTarget;
65+
66+
if (el.clientHeight + el.scrollTop + e.deltaY >= el.scrollHeight) {
67+
e.preventDefault();
68+
el.scrollTop = el.scrollHeight;
69+
} else if (el.scrollTop + e.deltaY <= 0) {
70+
e.preventDefault();
71+
el.scrollTop = 0;
72+
}
73+
74+
this.props.onWheel(e);
75+
}
76+
}, {
77+
key: "render",
78+
value: function render() {
79+
var _this = this;
80+
81+
var Tag = this.props.tagName;
82+
var props = Object.assign({}, this.props);
83+
delete props.tagName;
84+
return _react["default"].createElement(Tag, _extends({
85+
ref: function ref(_ref) {
86+
return _this.scroller = _ref;
87+
}
88+
}, props), this.props.children);
89+
}
90+
}]);
91+
92+
return ListScrollBound;
93+
}(_react.Component);
94+
95+
exports["default"] = ListScrollBound;
96+
97+
_defineProperty(ListScrollBound, "propTypes", {
98+
tagName: _propTypes["default"].string,
99+
onWheel: _propTypes["default"].func
100+
});
101+
102+
_defineProperty(ListScrollBound, "defaultProps", {
103+
tagName: 'ul',
104+
onWheel: function onWheel() {}
105+
});

‎package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
{
2-
"name": "react-list-scroll-bound",
2+
"name": "react-scroll-bound",
33
"version": "16.12.0",
44
"description": "prevent parent scrolling, if list scroll end reached, for better experience",
5-
"main": "dist/listScrollBound.js",
5+
"main": "dist/scrollBound.js",
66
"repository": {
77
"type": "git",
8-
"url": "https://github.com/fluse/react-list-scroll-bound.git"
8+
"url": "https://github.com/fluse/react-scroll-bound.git"
99
},
1010
"keywords": [
1111
"react",
1212
"react-component",
1313
"reactjs",
1414
"component",
1515
"scrolling",
16-
"prevent body",
16+
"prevent parent scrolling",
17+
"scroll bound",
1718
"prevention",
18-
"onWheel",
19-
"list"
19+
"onWheel"
2020
],
2121
"author": "Holger D. Schauf",
2222
"website": "https://github.com/fluse/",
2323
"license": "MIT",
2424
"bugs": {
25-
"url": "https://github.com/fluse/react-list-scroll-bound/issues"
25+
"url": "https://github.com/fluse/react-scroll-bound/issues"
2626
},
2727
"homepage": "https://github.com/fluse/react-list-scroll-bound",
2828
"scripts": {
2929
"start": "webpack-dev-server --open --mode development",
3030
"page": "webpack --mode production --output-path page",
31-
"build": "babel src/listScrollBound.jsx --out-dir dist"
31+
"build": "babel src/scrollBound.jsx --out-dir dist"
3232
},
3333
"devDependencies": {
3434
"@babel/cli": "^7.7.4",

0 commit comments

Comments
 (0)
Please sign in to comment.