MikaFil commited on
Commit
ea755ec
·
verified ·
1 Parent(s): 54a50fa

Update interface.js

Browse files
Files changed (1) hide show
  1. interface.js +31 -0
interface.js CHANGED
@@ -141,6 +141,37 @@ const currentScriptTag = document.currentScript;
141
  '- Cliquez sur ⇱ pour passer en plein écran.<br>';
142
  }
143
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  menuContent.style.display = isMobile ? 'none' : 'block';
145
 
146
  viewerContainerElem.style.display = 'block';
 
141
  '- Cliquez sur ⇱ pour passer en plein écran.<br>';
142
  }
143
 
144
+
145
+ // --- Limit menu-content max size to 80% of the viewer (on mobile) ---
146
+ function setMenuContentMaxSize() {
147
+ if (!isMobile) {
148
+ menuContent.style.maxWidth = "";
149
+ menuContent.style.maxHeight = "";
150
+ menuContent.style.overflowY = "";
151
+ menuContent.style.overflowX = "";
152
+ return;
153
+ }
154
+ let parent = viewerContainerElem;
155
+ if (parent) {
156
+ const vw = parent.offsetWidth;
157
+ const vh = parent.offsetHeight;
158
+ if (vw && vh) {
159
+ menuContent.style.maxWidth = Math.round(vw * 0.8) + "px";
160
+ menuContent.style.maxHeight = Math.round(vh * 0.8) + "px";
161
+ menuContent.style.overflowY = "auto";
162
+ menuContent.style.overflowX = "auto";
163
+ } else {
164
+ menuContent.style.maxWidth = "80vw";
165
+ menuContent.style.maxHeight = "80vh";
166
+ }
167
+ }
168
+ }
169
+ setMenuContentMaxSize();
170
+ window.addEventListener('resize', setMenuContentMaxSize);
171
+ document.addEventListener('fullscreenchange', setMenuContentMaxSize);
172
+ window.addEventListener('orientationchange', setMenuContentMaxSize);
173
+
174
+
175
  menuContent.style.display = isMobile ? 'none' : 'block';
176
 
177
  viewerContainerElem.style.display = 'block';