Skip to content

Commit 8c707fe

Browse files
authored
Merge pull request #242 from adobecom/aexg5198
AEXG5198 | ENUS, UK, IN | (mWeb) Homepage Test : Scroll Fix
2 parents 80699b1 + 75e9de9 commit 8c707fe

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

express/code/scripts/mep/aexg5198/mobile-fork-button/mobile-fork-button.css

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ main .mobile-fork-button.long-text {
1414
main .mobile-fork-button.mweb-mobile-fork::after {
1515
content: '';
1616
position: fixed;
17-
width: 100vh;
18-
height: 100vh;
17+
pointer-events: initial;
1918
top: 0;
19+
bottom: 0;
20+
left: 0;
21+
right: 0;
2022
background-color: rgba(0, 0, 0, .44);
2123
}
2224

express/code/scripts/mep/aexg5198/mobile-fork-button/mobile-fork-button.js

+8-16
Original file line numberDiff line numberDiff line change
@@ -115,22 +115,13 @@ function collectFloatingButtonData() {
115115
}
116116

117117
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>`;
126118
const newBlock = createTag(
127119
'div',
128120
{ class: 'floating-button-wrapper' },
129121
'<div class="floating-button meta-powered"><div>mobile</div></div>',
130122
);
131123
const oldBlock = document.querySelector('.mobile-fork-button');
132124
oldBlock.replaceWith(newBlock);
133-
// block.outerHTML = blockHTML;
134125

135126
const audience = 'mobile';
136127
const data = collectFloatingButtonData();
@@ -141,8 +132,11 @@ async function mWebStickyCTA() {
141132
}
142133

143134
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') {
146140
document.body.style.overflow = 'hidden';
147141
} else {
148142
document.body.style.overflow = '';
@@ -152,13 +146,11 @@ function mWebOverlayScroll() {
152146
function mWebBuildElements() {
153147
const mobileForkButton = document.querySelector('.mobile-fork-button');
154148
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 = `
159150
<svg width="13" height="12" viewBox="0 0 13 12" fill="none" xmlns="http://www.w3.org/2000/svg">
160151
<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"/>
161152
</svg>`;
153+
const closeElement = createTag('a', { class: 'mweb-close' }, svg);
162154
mobileForkButton.querySelector('div:first-child').prepend(closeElement);
163155
}
164156

@@ -167,8 +159,8 @@ function mWebCloseEvents() {
167159
closeElements.forEach((element) => {
168160
element.addEventListener('click', (event) => {
169161
event.preventDefault();
170-
mWebOverlayScroll();
171162
mWebStickyCTA();
163+
mWebOverlayScroll();
172164
});
173165
});
174166
}

0 commit comments

Comments
 (0)