@@ -115,22 +115,13 @@ function collectFloatingButtonData() {
115
115
}
116
116
117
117
async function mWebStickyCTA ( ) {
118
- // const blockHTML = `
119
- // <div class="section" data-status="decorated" data-idx="8">
120
- // <div class="floating-button-wrapper">
121
- // <div class="floating-button meta-powered">
122
- // <div>mobile</div>
123
- // </div>
124
- // </div>
125
- // </div>`;
126
118
const newBlock = createTag (
127
119
'div' ,
128
120
{ class : 'floating-button-wrapper' } ,
129
121
'<div class="floating-button meta-powered"><div>mobile</div></div>' ,
130
122
) ;
131
123
const oldBlock = document . querySelector ( '.mobile-fork-button' ) ;
132
124
oldBlock . replaceWith ( newBlock ) ;
133
- // block.outerHTML = blockHTML;
134
125
135
126
const audience = 'mobile' ;
136
127
const data = collectFloatingButtonData ( ) ;
@@ -141,8 +132,11 @@ async function mWebStickyCTA() {
141
132
}
142
133
143
134
function mWebOverlayScroll ( ) {
144
- const mobileForkButton = document . querySelector ( '.mobile-fork-button' ) ;
145
- if ( mobileForkButton && mobileForkButton . classList . contains ( 'mweb-mobile-fork' ) ) {
135
+ // This is to make scroll work when switching between mobile and desktop.
136
+ // May need rewrite for RTP.
137
+ const mobileForkButton = document . querySelector ( '.mobile-fork-button.mweb-mobile-fork' ) ;
138
+ if ( mobileForkButton
139
+ && window . getComputedStyle ( mobileForkButton , null ) . display !== 'none' ) {
146
140
document . body . style . overflow = 'hidden' ;
147
141
} else {
148
142
document . body . style . overflow = '' ;
@@ -152,13 +146,11 @@ function mWebOverlayScroll() {
152
146
function mWebBuildElements ( ) {
153
147
const mobileForkButton = document . querySelector ( '.mobile-fork-button' ) ;
154
148
mobileForkButton . classList . add ( 'mweb-mobile-fork' ) ;
155
-
156
- const closeElement = document . createElement ( 'a' ) ;
157
- closeElement . classList . add ( 'mweb-close' ) ;
158
- closeElement . innerHTML = `
149
+ const svg = `
159
150
<svg width="13" height="12" viewBox="0 0 13 12" fill="none" xmlns="http://www.w3.org/2000/svg">
160
151
<path d="M7.45455 5.99986L12.1404 1.31442C12.4041 1.05075 12.4041 0.623598 12.1404 0.359925C11.8767 0.0962522 11.4496 0.0962522 11.1859 0.359925L6.5 5.04537L1.81412 0.359925C1.55044 0.0962522 1.12329 0.0962522 0.85962 0.359925C0.595947 0.623598 0.595947 1.05075 0.85962 1.31442L5.54545 5.99986L0.85962 10.6853C0.595947 10.949 0.595947 11.3761 0.85962 11.6398C0.991452 11.7716 1.16416 11.8376 1.33686 11.8376C1.50956 11.8376 1.68227 11.7716 1.81411 11.6398L6.49999 6.95436L11.1859 11.6398C11.3177 11.7716 11.4904 11.8376 11.6631 11.8376C11.8358 11.8376 12.0085 11.7716 12.1404 11.6398C12.404 11.3761 12.404 10.949 12.1404 10.6853L7.45455 5.99986Z" fill="#292929"/>
161
152
</svg>` ;
153
+ const closeElement = createTag ( 'a' , { class : 'mweb-close' } , svg ) ;
162
154
mobileForkButton . querySelector ( 'div:first-child' ) . prepend ( closeElement ) ;
163
155
}
164
156
@@ -167,8 +159,8 @@ function mWebCloseEvents() {
167
159
closeElements . forEach ( ( element ) => {
168
160
element . addEventListener ( 'click' , ( event ) => {
169
161
event . preventDefault ( ) ;
170
- mWebOverlayScroll ( ) ;
171
162
mWebStickyCTA ( ) ;
163
+ mWebOverlayScroll ( ) ;
172
164
} ) ;
173
165
} ) ;
174
166
}
0 commit comments