Skip to content

Commit 2bd6d9a

Browse files
committed
fix: add image zoom in
1 parent d754e24 commit 2bd6d9a

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

django_wtf/templates/core/base.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,6 @@
4343
<script src="https://unpkg.com/[email protected]"></script>
4444
{% django_htmx_script %}
4545
</body>
46+
{% block js %}
47+
{% endblock js %}
4648
</html>

django_wtf/templates/core/repository_detail.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,26 @@
9898
</div>
9999
</div>
100100
{% endblock content %}
101+
102+
{% block js %}
103+
{{ block.super }}
104+
<script src="https://cdnjs.cloudflare.com/ajax/libs/medium-zoom/1.0.6/medium-zoom.min.js"
105+
integrity="sha512-N9IJRoc3LaP3NDoiGkcPa4gG94kapGpaA5Zq9/Dr04uf5TbLFU5q0o8AbRhLKUUlp8QFS2u7S+Yti0U7QtuZvQ=="
106+
crossorigin="anonymous"
107+
referrerpolicy="no-referrer"></script>
108+
<script>
109+
const images = Array.from(document.querySelectorAll(".prose img"));
110+
console.log(images)
111+
images.forEach(img => {
112+
mediumZoom(img, {
113+
margin: 0,
114+
/* The space outside the zoomed image */
115+
scrollOffset: 40,
116+
/* The number of pixels to scroll to close the zoom */
117+
container: null,
118+
/* The viewport to render the zoom in */
119+
template: null /* The template element to display on zoom */
120+
});
121+
});
122+
</script>
123+
{% endblock js %}

0 commit comments

Comments
 (0)