File tree 1 file changed +12
-8
lines changed
1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,13 @@ const React = require('react')
3
3
const onElementResize = require ( 'element-resize-event' )
4
4
const unbind = require ( 'element-resize-event' ) . unbind
5
5
6
+ const defaultContainerStyle = {
7
+ width : '100%' ,
8
+ height : '100%' ,
9
+ padding : 0 ,
10
+ border : 0
11
+ }
12
+
6
13
function defaultGetDimensions ( element ) {
7
14
return [ element . clientWidth , element . clientHeight ]
8
15
}
@@ -74,11 +81,12 @@ function defaultGetDimensions (element) {
74
81
* module.exports = Dimensions()(MyComponent) // Enhanced component
75
82
*
76
83
*/
77
- module . exports = function Dimensions ( {
84
+ export default function Dimensions ( {
78
85
getDimensions = defaultGetDimensions ,
79
86
debounce = 0 ,
80
87
debounceOpts = { } ,
81
- elementResize = false
88
+ elementResize = false ,
89
+ containerStyle = defaultContainerStyle
82
90
} = { } ) {
83
91
return ( ComposedComponent ) => {
84
92
return class DimensionsHOC extends React . Component {
@@ -165,13 +173,9 @@ module.exports = function Dimensions ({
165
173
// only trigger a warning about the wrapper div if we already have a reference to it
166
174
console . warn ( 'Wrapper div has no height or width, try overriding style with `containerStyle` option' )
167
175
}
168
- const wrapperStyle = {
169
- overflow : 'visible' ,
170
- height : 0 ,
171
- width : 0
172
- }
176
+
173
177
return (
174
- < div style = { wrapperStyle } ref = 'wrapper' >
178
+ < div style = { containerStyle } ref = 'wrapper' >
175
179
{ ( containerWidth || containerHeight )
176
180
? < ComposedComponent
177
181
{ ...this . state }
You can’t perform that action at this time.
0 commit comments