Zoom and Pan: use for instead of forEach

This commit is contained in:
Aarni Koskela 2023-06-05 10:36:45 +03:00
parent afbb0b5f86
commit 6163b38ad9

View File

@ -150,17 +150,15 @@ onUiLoaded(async() => {
const elemData = {}; const elemData = {};
// Apply functionality to the range inputs. Restore redmask and correct for long images. // Apply functionality to the range inputs. Restore redmask and correct for long images.
const rangeInputs = elements.rangeGroup ? elements.rangeGroup.querySelectorAll("input") : const rangeInputs = elements.rangeGroup ? Array.from(elements.rangeGroup.querySelectorAll("input")) :
[ [
gradioApp().querySelector("#img2img_width input[type='range']"), gradioApp().querySelector("#img2img_width input[type='range']"),
gradioApp().querySelector("#img2img_height input[type='range']") gradioApp().querySelector("#img2img_height input[type='range']")
]; ];
rangeInputs.forEach(input => { for (const input of rangeInputs) {
if (input) { input?.addEventListener("input", () => restoreImgRedMask(elements));
input.addEventListener("input", () => restoreImgRedMask(elements)); }
}
});
function applyZoomAndPan(elemId) { function applyZoomAndPan(elemId) {
const targetElement = gradioApp().querySelector(elemId); const targetElement = gradioApp().querySelector(elemId);
@ -215,12 +213,11 @@ onUiLoaded(async() => {
action: "Move canvas" action: "Move canvas"
} }
]; ];
hotkeys.forEach(function(hotkey) { for (const hotkey of hotkeys) {
const p = document.createElement("p"); const p = document.createElement("p");
p.innerHTML = p.innerHTML = `<b>${hotkey.key}</b> - ${hotkey.action}`;
"<b>" + hotkey.key + "</b>" + " - " + hotkey.action;
tooltipContent.appendChild(p); tooltipContent.appendChild(p);
}); }
// Add information and content elements to the tooltip element // Add information and content elements to the tooltip element
tooltip.appendChild(info); tooltip.appendChild(info);