Skip to content

Commit

Permalink
Eliminate layout shift when viewing submission files
Browse files Browse the repository at this point in the history
Give hints about dimensions so that the browser can immediatly do proper layout
  • Loading branch information
Earlopain committed Oct 3, 2023
1 parent 355af0b commit 472b14b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/stylesheet/specific/submission_files.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
.submission-file {
max-width: 100%;
max-height: 250px;
object-fit: contain;
object-position: bottom;
}

.selected {
Expand Down
2 changes: 1 addition & 1 deletion app/views/submission_files/_sample.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<% if submission_file.sample_generated? %>
<div class="file-container">
<% if submission_file.sample.content_type.in? %w[image/jpeg image/gif] %>
<%= image_tag url_for(submission_file.sample), loading: "lazy", class: "submission-file" %>
<%= image_tag url_for(submission_file.sample), loading: "lazy", class: "submission-file", width: submission_file.width, height: submission_file.height %>
<%= original_file_tag(submission_file) %>
<% else %>
Unhandled content_type <%= submission_file.sample.content_type %>
Expand Down

0 comments on commit 472b14b

Please sign in to comment.