From 44cd01673c67166d882eeaa3b19f4f131ca02e22 Mon Sep 17 00:00:00 2001 From: Jedrzej Kosinski Date: Sat, 21 Oct 2023 11:39:32 -0500 Subject: [PATCH] Revert "Merge pull request #21 from kijai/main" This reverts commit b2c4b4a5ac19ce1ddcc6118ca8d9561c25a5f25c, reversing changes made to f032b046afbd18a392ae4850337c3a1f42841c83. --- web/js/gif_preview.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/web/js/gif_preview.js b/web/js/gif_preview.js index 25a748f..2ceed84 100644 --- a/web/js/gif_preview.js +++ b/web/js/gif_preview.js @@ -87,14 +87,13 @@ const CreatePreviewElement = (name, val, format) => { w.inputEl = document.createElement(type === 'video' ? 'video' : 'img') w.inputEl.src = w.value - w.inputEl.id = "vhs_gif_preview" + w.inputEl.onload = function() { w.inputRatio = w.inputEl.naturalWidth / w.inputEl.naturalHeight if (type === 'video') { setTimeout(_=>{ w.inputEl.setAttribute('type', 'video/webm'); - w.inputEl.id = "vhs_video_preview" w.inputEl.muted = true; w.inputEl.autoplay = true w.inputEl.loop = true @@ -103,6 +102,10 @@ const CreatePreviewElement = (name, val, format) => { } } document.body.appendChild(w.inputEl) + const videoElements = document.querySelectorAll('video'); + videoElements.forEach(video => { + video.currentTime = 0; + }); return w } @@ -111,18 +114,14 @@ const gif_preview = { async beforeRegisterNodeDef(nodeType, nodeData, app) { switch (nodeData.name) { case 'VHS_VideoCombine': { - nodeType.prototype.onNodeCreated = function () { + nodeType.prototype.onNodeCreated = function() { this.addWidget("button", "Sync playback", null, () => { - const videoElements = document.querySelectorAll('#vhs_video_preview'); - const gifElements = document.querySelectorAll('#vhs_gif_preview'); - videoElements.forEach(video => { - video.currentTime = 0; - }); - gifElements.forEach(gif => { - gif.src = gif.src; - }); + const videoElements = document.querySelectorAll('video'); + videoElements.forEach(video => { + video.currentTime = 0; + }); }); - } + } const onExecuted = nodeType.prototype.onExecuted nodeType.prototype.onExecuted = function(message) { const prefix = 'vhs_gif_preview_'