File tree 1 file changed +15
-1
lines changed
1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,11 @@ class AutoAffix extends React.Component {
32
32
this . _windowScrollListener = addEventListener (
33
33
ownerWindow ( this ) , 'scroll' , ( ) => this . onWindowScroll ( )
34
34
) ;
35
+
36
+ this . _windowResizeListener = addEventListener (
37
+ ownerWindow ( this ) , 'resize' , ( ) => this . onWindowResize ( )
38
+ ) ;
39
+
35
40
this . _documentClickListener = addEventListener (
36
41
ownerDocument ( this ) , 'click' , ( ) => this . onDocumentClick ( )
37
42
) ;
@@ -59,12 +64,21 @@ class AutoAffix extends React.Component {
59
64
if ( this . _documentClickListener ) {
60
65
this . _documentClickListener . remove ( ) ;
61
66
}
67
+ if ( this . _windowResizeListener ) {
68
+ this . _windowResizeListener . remove ( ) ;
69
+ }
62
70
}
63
71
64
72
onWindowScroll ( ) {
65
73
this . onUpdate ( ) ;
66
74
}
67
75
76
+ onWindowResize ( ) {
77
+ if ( this . props . autoWidth ) {
78
+ requestAnimationFrame ( ( ) => this . onUpdate ( ) ) ;
79
+ }
80
+ }
81
+
68
82
onDocumentClick ( ) {
69
83
requestAnimationFrame ( ( ) => this . onUpdate ( ) ) ;
70
84
}
@@ -119,12 +133,12 @@ class AutoAffix extends React.Component {
119
133
< div ref = "positioner" />
120
134
121
135
< Affix
136
+ { ...props }
122
137
offsetTop = { effectiveOffsetTop }
123
138
viewportOffsetTop = { viewportOffsetTop }
124
139
offsetBottom = { offsetBottom }
125
140
affixStyle = { affixStyle }
126
141
bottomStyle = { bottomStyle }
127
- { ...props }
128
142
>
129
143
{ children }
130
144
</ Affix >
You can’t perform that action at this time.
0 commit comments