bilca commited on
Commit
e7d95af
·
verified ·
1 Parent(s): 8a0c174

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +42 -15
index.js CHANGED
@@ -20,6 +20,9 @@
20
  var minAngle = parseFloat(getScriptQueryParam("minAngle")) || 0;
21
  var maxAngle = parseFloat(getScriptQueryParam("maxAngle")) || 90;
22
 
 
 
 
23
  // Inject CSS styles into the document head.
24
  var styleEl = document.createElement('style');
25
  styleEl.textContent = `
@@ -30,6 +33,16 @@
30
  height: 0;
31
  padding-bottom: 100%;
32
  }
 
 
 
 
 
 
 
 
 
 
33
  /* GIF Preview styling */
34
  #gif-preview-container {
35
  position: absolute;
@@ -82,8 +95,8 @@
82
  #menu-content {
83
  display: none;
84
  position: absolute;
85
- top: 62px;
86
- right: 70px;
87
  background: #FFFEF4;
88
  border: 1px solid #474558;
89
  border-radius: 5px;
@@ -184,30 +197,44 @@
184
  document.exitFullscreen();
185
  }
186
  }
 
 
187
  viewerContainer.style.display = 'none';
188
  gifPreview.style.display = 'block';
189
  });
190
 
191
- // Fullscreen toggle: toggle fullscreen on the widget container.
192
  fullscreenToggle.addEventListener('click', function() {
193
- if (!document.fullscreenElement) {
194
- if (widgetContainer.requestFullscreen) {
195
- widgetContainer.requestFullscreen();
196
- } else if (widgetContainer.webkitRequestFullscreen) {
197
- widgetContainer.webkitRequestFullscreen();
198
- } else if (widgetContainer.mozRequestFullScreen) {
199
- widgetContainer.mozRequestFullScreen();
200
- } else if (widgetContainer.msRequestFullscreen) {
201
- widgetContainer.msRequestFullscreen();
202
  }
 
 
203
  } else {
204
- if (document.exitFullscreen) {
205
- document.exitFullscreen();
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  }
207
  }
208
  });
209
 
210
- // Update the fullscreen button icon on fullscreen change.
211
  document.addEventListener('fullscreenchange', function() {
212
  if (document.fullscreenElement === widgetContainer) {
213
  fullscreenToggle.textContent = '⇲';
 
20
  var minAngle = parseFloat(getScriptQueryParam("minAngle")) || 0;
21
  var maxAngle = parseFloat(getScriptQueryParam("maxAngle")) || 90;
22
 
23
+ // Detect if the device is iOS.
24
+ var isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
25
+
26
  // Inject CSS styles into the document head.
27
  var styleEl = document.createElement('style');
28
  styleEl.textContent = `
 
33
  height: 0;
34
  padding-bottom: 100%;
35
  }
36
+ /* When in fake fullscreen mode (iOS fallback) */
37
+ #ply-widget-container.fake-fullscreen {
38
+ position: fixed !important;
39
+ top: 0 !important;
40
+ left: 0 !important;
41
+ width: 100vw !important;
42
+ height: 100vh !important;
43
+ padding-bottom: 0 !important;
44
+ z-index: 9999 !important;
45
+ }
46
  /* GIF Preview styling */
47
  #gif-preview-container {
48
  position: absolute;
 
95
  #menu-content {
96
  display: none;
97
  position: absolute;
98
+ top: 72px;
99
+ right: 15px;
100
  background: #FFFEF4;
101
  border: 1px solid #474558;
102
  border-radius: 5px;
 
197
  document.exitFullscreen();
198
  }
199
  }
200
+ // Remove fake-fullscreen class (for iOS) if present.
201
+ widgetContainer.classList.remove('fake-fullscreen');
202
  viewerContainer.style.display = 'none';
203
  gifPreview.style.display = 'block';
204
  });
205
 
206
+ // Fullscreen toggle: use native Fullscreen API if available; otherwise, for iOS, toggle a CSS-based fullscreen.
207
  fullscreenToggle.addEventListener('click', function() {
208
+ if (isIOS) {
209
+ // Toggle fake fullscreen via CSS on iOS.
210
+ if (!widgetContainer.classList.contains('fake-fullscreen')) {
211
+ widgetContainer.classList.add('fake-fullscreen');
212
+ } else {
213
+ widgetContainer.classList.remove('fake-fullscreen');
 
 
 
214
  }
215
+ // Update icon based on state.
216
+ fullscreenToggle.textContent = widgetContainer.classList.contains('fake-fullscreen') ? '⇲' : '⇱';
217
  } else {
218
+ // Non-iOS: use standard Fullscreen API.
219
+ if (!document.fullscreenElement) {
220
+ if (widgetContainer.requestFullscreen) {
221
+ widgetContainer.requestFullscreen();
222
+ } else if (widgetContainer.webkitRequestFullscreen) {
223
+ widgetContainer.webkitRequestFullscreen();
224
+ } else if (widgetContainer.mozRequestFullScreen) {
225
+ widgetContainer.mozRequestFullScreen();
226
+ } else if (widgetContainer.msRequestFullscreen) {
227
+ widgetContainer.msRequestFullscreen();
228
+ }
229
+ } else {
230
+ if (document.exitFullscreen) {
231
+ document.exitFullscreen();
232
+ }
233
  }
234
  }
235
  });
236
 
237
+ // Update the fullscreen button icon on fullscreen change (for non-iOS browsers).
238
  document.addEventListener('fullscreenchange', function() {
239
  if (document.fullscreenElement === widgetContainer) {
240
  fullscreenToggle.textContent = '⇲';