Skip to content

Commit

Permalink
Handle right panel setting of src async
Browse files Browse the repository at this point in the history
  • Loading branch information
will-moore committed Dec 4, 2024
1 parent b3f58ae commit f0f89c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/js/views/right_panel_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -1043,9 +1043,14 @@
var frame_h = this.full_size / wh;
}
this.models.forEach(function(m){
var src = m.get_img_src();
var img_id = "image_" + Math.random();
// src is async, so we set an id instead. When src returns we
// use the ID to find the element and set the src.
m.get_img_src().then(src => {
document.getElementById(img_id).src = src;
});
var img_css = m.get_vp_img_css(m.get('zoom'), frame_w, frame_h);
img_css.src = src;
img_css.id = img_id;
// if a 'reasonable' dpi is set, we don't pixelate
var dpiSet = m.get('min_export_dpi') > 100;
img_css.pixelated = !dpiSet;
Expand Down
3 changes: 2 additions & 1 deletion src/templates/viewport_inner.template.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

<% _.each(imgs_css, function(css, i) { %>
<img class="vp_img<% if (css.pixelated) {%> pixelated<% } %>"
<img id='<%= css.id %>'
class="vp_img<% if (css.pixelated) {%> pixelated<% } %>"
style="opacity:<%= opacity %>; left:<%= css.left %>px; top:<%= css.top %>px;
width:<%= css.width %>px; height:<%= css.height %>px;
-webkit-transform-origin:<%= css['transform-origin'] %>;
Expand Down

0 comments on commit f0f89c3

Please sign in to comment.