Spaces:
Sleeping
Sleeping
Merge branch 'gradio-5.29.0'
Browse files
gradio_dualvision/app_template.py
CHANGED
|
@@ -251,38 +251,6 @@ class DualVisionApp(gr.Blocks):
|
|
| 251 |
}}
|
| 252 |
"""
|
| 253 |
if squeeze_canvas:
|
| 254 |
-
self.head += f"""
|
| 255 |
-
<script>
|
| 256 |
-
// fixes vertical size of the component when used inside of iframeResizer (on spaces)
|
| 257 |
-
function squeezeViewport() {{
|
| 258 |
-
if (typeof window.parentIFrame === "undefined") return;
|
| 259 |
-
const images = document.querySelectorAll('.slider img');
|
| 260 |
-
window.parentIFrame.getPageInfo((info) => {{
|
| 261 |
-
images.forEach((img) => {{
|
| 262 |
-
const imgMaxHeightNew = (info.clientHeight * {squeeze_viewport_height_pct}) / 100;
|
| 263 |
-
img.style.maxHeight = `${{imgMaxHeightNew}}px`;
|
| 264 |
-
// window.parentIFrame.size(0, null); // tighten the layout; body's flex-grow: 0 is less intrusive
|
| 265 |
-
}});
|
| 266 |
-
}});
|
| 267 |
-
}}
|
| 268 |
-
window.addEventListener('resize', squeezeViewport);
|
| 269 |
-
|
| 270 |
-
// fixes gradio-imageslider wrong position behavior when using fitting to content by triggering resize
|
| 271 |
-
let observer = new MutationObserver((mutationsList) => {{
|
| 272 |
-
const images = document.querySelectorAll('.slider img');
|
| 273 |
-
images.forEach((img) => {{
|
| 274 |
-
if (img.complete) {{
|
| 275 |
-
window.dispatchEvent(new Event('resize'));
|
| 276 |
-
}} else {{
|
| 277 |
-
img.onload = () => {{
|
| 278 |
-
window.dispatchEvent(new Event('resize'));
|
| 279 |
-
}}
|
| 280 |
-
}}
|
| 281 |
-
}});
|
| 282 |
-
}});
|
| 283 |
-
observer.observe(document.body, {{ childList: true, subtree: true }});
|
| 284 |
-
</script>
|
| 285 |
-
"""
|
| 286 |
self.css += f"""
|
| 287 |
.slider {{ /* make the slider dimensions fit to the uploaded content dimensions */
|
| 288 |
max-width: fit-content;
|
|
|
|
| 251 |
}}
|
| 252 |
"""
|
| 253 |
if squeeze_canvas:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 254 |
self.css += f"""
|
| 255 |
.slider {{ /* make the slider dimensions fit to the uploaded content dimensions */
|
| 256 |
max-width: fit-content;
|