Spaces:
Runtime error
Runtime error
added a full screen loader
Browse files- templates/index.html +17 -7
templates/index.html
CHANGED
|
@@ -155,22 +155,34 @@
|
|
| 155 |
|
| 156 |
</div>
|
| 157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
<!-- Cropper.js -->
|
| 159 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/cropperjs/1.5.13/cropper.min.js"></script>
|
| 160 |
|
| 161 |
<script>
|
| 162 |
let cropper;
|
| 163 |
|
| 164 |
-
//
|
| 165 |
document.getElementById('tryon-form').addEventListener('submit', function(e) {
|
|
|
|
|
|
|
|
|
|
| 166 |
// If garment cropper is active → replace original file with cropped version
|
| 167 |
if (cropper) {
|
| 168 |
e.preventDefault();
|
| 169 |
|
| 170 |
cropper.getCroppedCanvas().toBlob((blob) => {
|
| 171 |
-
const file = new File([blob], "cropped_garment.png", {
|
| 172 |
-
type: "image/png"
|
| 173 |
-
});
|
| 174 |
|
| 175 |
// Replace original input
|
| 176 |
const dataTransfer = new DataTransfer();
|
|
@@ -180,10 +192,8 @@
|
|
| 180 |
// Now submit form
|
| 181 |
e.target.submit();
|
| 182 |
});
|
|
|
|
| 183 |
}
|
| 184 |
-
|
| 185 |
-
document.getElementById('placeholder-text').style.display = 'none';
|
| 186 |
-
document.getElementById('loading-spinner').style.display = 'flex';
|
| 187 |
});
|
| 188 |
|
| 189 |
// Change Person function
|
|
|
|
| 155 |
|
| 156 |
</div>
|
| 157 |
|
| 158 |
+
<!-- Global Full-screen Loader Overlay -->
|
| 159 |
+
<div id="global-loader" style="display:none;" class="fixed inset-0 z-50 bg-black/70 flex items-center justify-center">
|
| 160 |
+
<div class="flex flex-col items-center">
|
| 161 |
+
<svg class="animate-spin h-16 w-16 text-pink-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
| 162 |
+
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
| 163 |
+
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
| 164 |
+
</svg>
|
| 165 |
+
<p class="mt-4 text-lg">Processing... Please wait.</p>
|
| 166 |
+
</div>
|
| 167 |
+
</div>
|
| 168 |
+
|
| 169 |
<!-- Cropper.js -->
|
| 170 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/cropperjs/1.5.13/cropper.min.js"></script>
|
| 171 |
|
| 172 |
<script>
|
| 173 |
let cropper;
|
| 174 |
|
| 175 |
+
// Global loader on every submit
|
| 176 |
document.getElementById('tryon-form').addEventListener('submit', function(e) {
|
| 177 |
+
const overlay = document.getElementById('global-loader');
|
| 178 |
+
if (overlay) overlay.style.display = 'flex';
|
| 179 |
+
|
| 180 |
// If garment cropper is active → replace original file with cropped version
|
| 181 |
if (cropper) {
|
| 182 |
e.preventDefault();
|
| 183 |
|
| 184 |
cropper.getCroppedCanvas().toBlob((blob) => {
|
| 185 |
+
const file = new File([blob], "cropped_garment.png", { type: "image/png" });
|
|
|
|
|
|
|
| 186 |
|
| 187 |
// Replace original input
|
| 188 |
const dataTransfer = new DataTransfer();
|
|
|
|
| 192 |
// Now submit form
|
| 193 |
e.target.submit();
|
| 194 |
});
|
| 195 |
+
return;
|
| 196 |
}
|
|
|
|
|
|
|
|
|
|
| 197 |
});
|
| 198 |
|
| 199 |
// Change Person function
|