@@ -140,34 +140,36 @@ export default class Panel implements PanelInterface {
140
140
const panel = $ ( this . element ) ;
141
141
const stage = panel . siblings ( ".pagebuilder-stage" ) ;
142
142
$ ( window ) . scroll ( function ( ) {
143
- const panelOffsetTop = panel . offset ( ) . top ;
144
- const stageOffsetTop = stage . offset ( ) . top ;
145
- const panelHeight = panel . outerHeight ( ) ;
146
- const stageHeight = stage . outerHeight ( ) ;
147
- const currentPanelBottom = Math . round ( panelOffsetTop + panel . outerHeight ( true ) - $ ( this ) . scrollTop ( ) ) ;
148
- const currentStageBottom = Math . round ( stageOffsetTop + stage . outerHeight ( true ) - $ ( this ) . scrollTop ( ) ) ;
149
- const currentPanelTop = Math . round ( panelOffsetTop - $ ( this ) . scrollTop ( ) ) ;
150
- const currentStageTop = Math . round ( stageOffsetTop - $ ( this ) . scrollTop ( ) ) ;
151
- // When panel height is less than stage, begin stickiness
152
- if ( panelHeight <= stageHeight && pageActions . hasClass ( "_fixed" ) ) {
153
- const pageActionsHeight = pageActions . outerHeight ( ) + 15 ;
154
- // When scroll reaches top of stage, stick panel to top
155
- if ( currentStageTop <= pageActionsHeight ) {
156
- // When panel reaches bottom of stage, stick panel to bottom of stage
157
- if ( currentPanelBottom >= currentStageBottom && currentPanelTop <= pageActionsHeight ) {
158
- self . isStickyBottom ( true ) ;
159
- self . isStickyTop ( false ) ;
143
+ if ( panel && panel . offset ( ) ) {
144
+ const panelOffsetTop = panel . offset ( ) . top ;
145
+ const stageOffsetTop = stage . offset ( ) . top ;
146
+ const panelHeight = panel . outerHeight ( ) ;
147
+ const stageHeight = stage . outerHeight ( ) ;
148
+ const currentPanelBottom = Math . round ( panelOffsetTop + panel . outerHeight ( true ) - $ ( this ) . scrollTop ( ) ) ;
149
+ const currentStageBottom = Math . round ( stageOffsetTop + stage . outerHeight ( true ) - $ ( this ) . scrollTop ( ) ) ;
150
+ const currentPanelTop = Math . round ( panelOffsetTop - $ ( this ) . scrollTop ( ) ) ;
151
+ const currentStageTop = Math . round ( stageOffsetTop - $ ( this ) . scrollTop ( ) ) ;
152
+ // When panel height is less than stage, begin stickiness
153
+ if ( panelHeight <= stageHeight && pageActions . hasClass ( "_fixed" ) ) {
154
+ const pageActionsHeight = pageActions . outerHeight ( ) + 15 ;
155
+ // When scroll reaches top of stage, stick panel to top
156
+ if ( currentStageTop <= pageActionsHeight ) {
157
+ // When panel reaches bottom of stage, stick panel to bottom of stage
158
+ if ( currentPanelBottom >= currentStageBottom && currentPanelTop <= pageActionsHeight ) {
159
+ self . isStickyBottom ( true ) ;
160
+ self . isStickyTop ( false ) ;
161
+ } else {
162
+ self . isStickyBottom ( false ) ;
163
+ self . isStickyTop ( true ) ;
164
+ }
160
165
} else {
161
166
self . isStickyBottom ( false ) ;
162
- self . isStickyTop ( true ) ;
167
+ self . isStickyTop ( false ) ;
163
168
}
164
169
} else {
165
170
self . isStickyBottom ( false ) ;
166
171
self . isStickyTop ( false ) ;
167
172
}
168
- } else {
169
- self . isStickyBottom ( false ) ;
170
- self . isStickyTop ( false ) ;
171
173
}
172
174
} ) ;
173
175
}
0 commit comments