提交 6163b38a 编写于 作者: A Aarni Koskela

Zoom and Pan: use for instead of forEach

上级 afbb0b5f
...@@ -150,17 +150,15 @@ onUiLoaded(async() => { ...@@ -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() => { ...@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册