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
+ } ) ;
0 commit comments