Skip to content

Commit

Permalink
Fix missing width and height setting of canvas (#623)
Browse files Browse the repository at this point in the history
This fixes #622.
  • Loading branch information
Splines authored Apr 17, 2024
1 parent 098da70 commit 10de4ac
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/assets/javascripts/thyme/thyme_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ $(document).on("turbolinks:load", function () {
thymeAttributes.video = video;
thymeAttributes.mediumId = thymeEdit.dataset.medium;

const canvasId = "snapshot";

// Adjust the width of the canvas according to the video
// such that screenshot generation is performed with the same ratio.
video.addEventListener("loadedmetadata", () => {
this.canvas = document.getElementById(canvasId);
this.canvas.width = Math.floor($(video).width());
this.canvas.height = Math.floor($(video).height());
});

/*
COMPONENTS
*/
Expand All @@ -30,7 +40,7 @@ $(document).on("turbolinks:load", function () {

(new AddItemButton("add-item")).add();
(new AddReferenceButton("add-reference")).add();
(new AddScreenshotButton("add-screenshot", "snapshot")).add();
(new AddScreenshotButton("add-screenshot", canvasId)).add();

thymeUtility.setUpMaxTime("max-time");
});

0 comments on commit 10de4ac

Please sign in to comment.