feat: load widget image flow

This commit is contained in:
2026-06-24 07:59:52 +05:00
parent 5796a01a85
commit 99ebaceda3
5 changed files with 144 additions and 3 deletions
+18
View File
@@ -12,6 +12,22 @@ function applyBgToField(field, state) {
}
}
function applyWidgetImage(widget, state) {
if (state.widgetImage) {
widget.style.backgroundImage = `url(${state.widgetImage})`;
widget.style.backgroundSize = '100% 100%';
widget.style.backgroundPosition = 'center';
widget.style.backgroundRepeat = 'no-repeat';
widget.querySelector('span').style.display = 'none';
} else {
widget.style.backgroundImage = '';
widget.style.backgroundSize = '';
widget.style.backgroundPosition = '';
widget.style.backgroundRepeat = '';
widget.querySelector('span').style.display = '';
}
}
export function updateLivePreview(state) {
const container = $('fieldContainer');
const cw = container.clientWidth;
@@ -34,6 +50,8 @@ export function updateLivePreview(state) {
widget.style.width = state.widgetW + 'px';
widget.style.height = state.widgetH + 'px';
applyWidgetImage(widget, state);
const H = computeHomography(state);
if (H) {
const n = v => parseFloat(v.toFixed(6));