@@ -3874,7 +3874,6 @@ var HeightUpdater = (function (_Component) {
3874
3874
key : 'componentWillMount' ,
3875
3875
value : function componentWillMount ( ) {
3876
3876
window . addEventListener ( 'resize' , this . onWindowResize ) ;
3877
- this . onWindowResize ( ) ;
3878
3877
}
3879
3878
} , {
3880
3879
key : 'componentWillUnmount' ,
@@ -3908,6 +3907,64 @@ Object.defineProperty(exports, '__esModule', {
3908
3907
value : true
3909
3908
} ) ;
3910
3909
3910
+ var _createClass = ( function ( ) { 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 ) ; } } return function ( Constructor , protoProps , staticProps ) { if ( protoProps ) defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) defineProperties ( Constructor , staticProps ) ; return Constructor ; } ; } ) ( ) ;
3911
+
3912
+ var _get = function get ( _x , _x2 , _x3 ) { var _again = true ; _function: while ( _again ) { var object = _x , property = _x2 , receiver = _x3 ; _again = false ; if ( object === null ) object = Function . prototype ; var desc = Object . getOwnPropertyDescriptor ( object , property ) ; if ( desc === undefined ) { var parent = Object . getPrototypeOf ( object ) ; if ( parent === null ) { return undefined ; } else { _x = parent ; _x2 = property ; _x3 = receiver ; _again = true ; desc = parent = undefined ; continue _function; } } else if ( 'value' in desc ) { return desc . value ; } else { var getter = desc . get ; if ( getter === undefined ) { return undefined ; } return getter . call ( receiver ) ; } } } ;
3913
+
3914
+ function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { 'default' : obj } ; }
3915
+
3916
+ function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( 'Cannot call a class as a function' ) ; } }
3917
+
3918
+ function _inherits ( subClass , superClass ) { if ( typeof superClass !== 'function' && superClass !== null ) { throw new TypeError ( 'Super expression must either be null or a function, not ' + typeof superClass ) ; } subClass . prototype = Object . create ( superClass && superClass . prototype , { constructor : { value : subClass , enumerable : false , writable : true , configurable : true } } ) ; if ( superClass ) Object . setPrototypeOf ? Object . setPrototypeOf ( subClass , superClass ) : subClass . __proto__ = superClass ; }
3919
+
3920
+ var _react = ( typeof window !== "undefined" ? window [ 'React' ] : typeof global !== "undefined" ? global [ 'React' ] : null ) ;
3921
+
3922
+ var _react2 = _interopRequireDefault ( _react ) ;
3923
+
3924
+ var _propTypes = require ( 'prop-types' ) ;
3925
+
3926
+ var _propTypes2 = _interopRequireDefault ( _propTypes ) ;
3927
+
3928
+ var ScrollToTop = ( function ( _Component ) {
3929
+ _inherits ( ScrollToTop , _Component ) ;
3930
+
3931
+ function ScrollToTop ( ) {
3932
+ _classCallCheck ( this , ScrollToTop ) ;
3933
+
3934
+ _get ( Object . getPrototypeOf ( ScrollToTop . prototype ) , 'constructor' , this ) . apply ( this , arguments ) ;
3935
+ }
3936
+
3937
+ _createClass ( ScrollToTop , [ {
3938
+ key : 'componentDidMount' ,
3939
+ value : function componentDidMount ( ) {
3940
+ this . props . element ( ) . scrollTop = 0 ;
3941
+ }
3942
+ } , {
3943
+ key : 'render' ,
3944
+ value : function render ( ) {
3945
+ return null ;
3946
+ }
3947
+ } ] ) ;
3948
+
3949
+ return ScrollToTop ;
3950
+ } ) ( _react . Component ) ;
3951
+
3952
+ ScrollToTop . propTypes = {
3953
+ element : _propTypes2 [ 'default' ] . func . isRequired
3954
+ } ;
3955
+
3956
+ exports [ 'default' ] = ScrollToTop ;
3957
+ module . exports = exports [ 'default' ] ;
3958
+
3959
+ } ) . call ( this , typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : { } )
3960
+ } , { "prop-types" :100 } ] , 116 :[ function ( require , module , exports ) {
3961
+ ( function ( global ) {
3962
+ 'use strict' ;
3963
+
3964
+ Object . defineProperty ( exports , '__esModule' , {
3965
+ value : true
3966
+ } ) ;
3967
+
3911
3968
var _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 ; } ;
3912
3969
3913
3970
var _createClass = ( function ( ) { 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 ) ; } } return function ( Constructor , protoProps , staticProps ) { if ( protoProps ) defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) defineProperties ( Constructor , staticProps ) ; return Constructor ; } ; } ) ( ) ;
@@ -3936,6 +3993,10 @@ var _HeightUpdater = require('./HeightUpdater');
3936
3993
3937
3994
var _HeightUpdater2 = _interopRequireDefault ( _HeightUpdater ) ;
3938
3995
3996
+ var _ScrollToTop = require ( './ScrollToTop' ) ;
3997
+
3998
+ var _ScrollToTop2 = _interopRequireDefault ( _ScrollToTop ) ;
3999
+
3939
4000
var SwipeableBottomSheet = ( function ( _Component ) {
3940
4001
_inherits ( SwipeableBottomSheet , _Component ) ;
3941
4002
@@ -3944,8 +4005,13 @@ var SwipeableBottomSheet = (function (_Component) {
3944
4005
3945
4006
_get ( Object . getPrototypeOf ( SwipeableBottomSheet . prototype ) , 'constructor' , this ) . call ( this , props ) ;
3946
4007
4008
+ this . onHeightChange = this . onHeightChange . bind ( this ) ;
4009
+ this . onChangeIndex = this . onChangeIndex . bind ( this ) ;
4010
+ this . onTransitionEnd = this . onTransitionEnd . bind ( this ) ;
4011
+
3947
4012
this . state = {
3948
- open : props . defaultOpen
4013
+ open : props . defaultOpen ,
4014
+ height : window . innerHeight
3949
4015
} ;
3950
4016
}
3951
4017
@@ -3966,22 +4032,41 @@ var SwipeableBottomSheet = (function (_Component) {
3966
4032
}
3967
4033
}
3968
4034
} , {
3969
- key : 'render' ,
3970
- value : function render ( ) {
3971
- var _this = this ;
3972
-
4035
+ key : 'onTransitionEnd' ,
4036
+ value : function onTransitionEnd ( ) {
3973
4037
var _props = this . props ;
3974
4038
var overflowHeight = _props . overflowHeight ;
3975
- var fullScreen = _props . fullScreen ;
3976
- var open = _props . open ;
3977
- var topShadow = _props . topShadow ;
3978
- var shadowTip = _props . shadowTip ;
3979
- var overlay = _props . overlay ;
3980
4039
var swipeableViewsProps = _props . swipeableViewsProps ;
3981
4040
4041
+ if ( overflowHeight === 0 ) {
4042
+ this . bodyElt . scrollTop = 0 ;
4043
+ }
4044
+ if ( swipeableViewsProps . onTransitionEnd ) {
4045
+ swipeableViewsProps . onTransitionEnd ( ) ;
4046
+ }
4047
+ }
4048
+ } , {
4049
+ key : 'render' ,
4050
+ value : function render ( ) {
4051
+ var _this = this ;
4052
+
4053
+ var _props2 = this . props ;
4054
+ var overflowHeight = _props2 . overflowHeight ;
4055
+ var fullScreen = _props2 . fullScreen ;
4056
+ var marginTop = _props2 . marginTop ;
4057
+ var open = _props2 . open ;
4058
+ var topShadow = _props2 . topShadow ;
4059
+ var shadowTip = _props2 . shadowTip ;
4060
+ var overlay = _props2 . overlay ;
4061
+ var swipeableViewsProps = _props2 . swipeableViewsProps ;
4062
+ var scrollTopAtClose = _props2 . scrollTopAtClose ;
4063
+
4064
+ var hiddenWhenClosed = overflowHeight === 0 ;
3982
4065
var isControlled = open !== undefined ;
3983
4066
var isOpen = isControlled ? open : this . state . open ;
4067
+ var hideShadows = hiddenWhenClosed && ! isOpen ;
3984
4068
var index = isOpen ? 1 : 0 ;
4069
+ var maxHeight = this . state . height - marginTop ;
3985
4070
3986
4071
var styles = {
3987
4072
root : _extends ( {
@@ -3998,7 +4083,7 @@ var SwipeableBottomSheet = (function (_Component) {
3998
4083
} , swipeableViewsProps . style ) ,
3999
4084
container : _extends ( {
4000
4085
boxSizing : 'border-box'
4001
- } , topShadow && {
4086
+ } , topShadow && ! hideShadows && {
4002
4087
boxShadow : 'rgba(0, 0, 0, 0.156863) 0px -6px 5px'
4003
4088
} , swipeableViewsProps . containerStyle ) ,
4004
4089
slide : _extends ( {
@@ -4012,16 +4097,16 @@ var SwipeableBottomSheet = (function (_Component) {
4012
4097
body : _extends ( {
4013
4098
overflow : isOpen ? 'auto' : 'hidden' ,
4014
4099
backgroundColor : 'white' ,
4015
- height : fullScreen ? this . state . height : 'initial' ,
4016
- maxHeight : this . state . height
4100
+ height : fullScreen ? maxHeight : 'initial' ,
4101
+ maxHeight : maxHeight
4017
4102
} , this . props . bodyStyle )
4018
4103
} ,
4019
4104
overlay : _extends ( {
4020
4105
position : 'fixed' ,
4021
- height : '100vh' ,
4022
- width : '100vw' ,
4023
4106
top : 0 ,
4024
4107
right : 0 ,
4108
+ left : 0 ,
4109
+ height : this . state . height ,
4025
4110
transition : 'opacity 450ms' ,
4026
4111
pointerEvents : 'none' ,
4027
4112
backgroundColor : 'black' ,
@@ -4047,7 +4132,7 @@ var SwipeableBottomSheet = (function (_Component) {
4047
4132
{ style : styles . root } ,
4048
4133
_react2 [ 'default' ] . createElement ( _HeightUpdater2 [ 'default' ] , {
4049
4134
height : this . state . height ,
4050
- onHeightChange : this . onHeightChange . bind ( this )
4135
+ onHeightChange : this . onHeightChange
4051
4136
} ) ,
4052
4137
overlay && _react2 [ 'default' ] . createElement ( 'div' , { style : styles . overlay , onClick : function ( ) {
4053
4138
return _this . onChangeIndex ( 0 ) ;
@@ -4058,20 +4143,26 @@ var SwipeableBottomSheet = (function (_Component) {
4058
4143
index : index ,
4059
4144
axis : 'y' ,
4060
4145
enableMouseEvents : true ,
4061
- onChangeIndex : this . onChangeIndex . bind ( this )
4146
+ onChangeIndex : this . onChangeIndex
4062
4147
} , this . props . swipeableViewsProps , {
4148
+ onTransitionEnd : this . onTransitionEnd ,
4063
4149
style : styles . swiper . root ,
4064
4150
containerStyle : styles . swiper . container ,
4065
4151
slideStyle : styles . swiper . slide
4066
4152
} ) ,
4067
4153
_react2 [ 'default' ] . createElement (
4068
4154
'div' ,
4069
- { style : styles . swiper . body } ,
4155
+ { style : styles . swiper . body , ref : function ( elt ) {
4156
+ return _this . bodyElt = elt ;
4157
+ } } ,
4070
4158
this . props . children
4071
4159
) ,
4072
4160
_react2 [ 'default' ] . createElement ( 'div' , { style : styles . swiper . bottomSlide } )
4073
4161
) ,
4074
- shadowTip && _react2 [ 'default' ] . createElement ( 'div' , { style : styles . shadowTip } )
4162
+ shadowTip && ! hideShadows && _react2 [ 'default' ] . createElement ( 'div' , { style : styles . shadowTip } ) ,
4163
+ ! isOpen && scrollTopAtClose && ! hiddenWhenClosed && _react2 [ 'default' ] . createElement ( _ScrollToTop2 [ 'default' ] , { element : function ( ) {
4164
+ return _this . bodyElt ;
4165
+ } } )
4075
4166
) ;
4076
4167
}
4077
4168
} ] ) ;
@@ -4086,11 +4177,14 @@ SwipeableBottomSheet.propTypes = {
4086
4177
children : _propTypes2 [ 'default' ] . node . isRequired ,
4087
4178
defaultOpen : _propTypes2 [ 'default' ] . bool ,
4088
4179
fullScreen : _propTypes2 [ 'default' ] . bool ,
4180
+ marginTop : _propTypes2 [ 'default' ] . number ,
4089
4181
onChange : _propTypes2 [ 'default' ] . func ,
4182
+ onTransitionEnd : _propTypes2 [ 'default' ] . func ,
4090
4183
open : _propTypes2 [ 'default' ] . bool ,
4091
4184
overflowHeight : _propTypes2 [ 'default' ] . number ,
4092
4185
overlay : _propTypes2 [ 'default' ] . bool ,
4093
4186
overlayStyle : _propTypes2 [ 'default' ] . object ,
4187
+ scrollTopAtClose : _propTypes2 [ 'default' ] . bool ,
4094
4188
shadowTip : _propTypes2 [ 'default' ] . bool ,
4095
4189
style : _propTypes2 [ 'default' ] . object ,
4096
4190
swipeableViewsProps : _propTypes2 [ 'default' ] . object ,
@@ -4100,8 +4194,10 @@ SwipeableBottomSheet.propTypes = {
4100
4194
SwipeableBottomSheet . defaultProps = {
4101
4195
defaultOpen : false ,
4102
4196
fullScreen : false ,
4197
+ marginTop : 0 ,
4103
4198
overflowHeight : 0 ,
4104
4199
overlay : true ,
4200
+ scrollTopAtClose : true ,
4105
4201
shadowTip : true ,
4106
4202
swipeableViewsProps : { } ,
4107
4203
topShadow : true
@@ -4111,5 +4207,5 @@ exports['default'] = SwipeableBottomSheet;
4111
4207
module . exports = exports [ 'default' ] ;
4112
4208
4113
4209
} ) . call ( this , typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : { } )
4114
- } , { "./HeightUpdater" :114 , "prop-types" :100 , "react-swipeable-views" :112 } ] } , { } , [ 115 ] ) ( 115 )
4210
+ } , { "./HeightUpdater" :114 , "./ScrollToTop" : 115 , " prop-types" :100 , "react-swipeable-views" :112 } ] } , { } , [ 116 ] ) ( 116 )
4115
4211
} ) ;
0 commit comments