Fix some crashes and improve pixel alignment

This commit is contained in:
Andrew Kingston 2024-07-31 14:12:46 +01:00
parent 0ea9b157c7
commit e385c7291c
No known key found for this signature in database
3 changed files with 7 additions and 8 deletions

View File

@ -69,7 +69,7 @@
z-index: var(--zIndex);
border: 2px solid var(--color);
pointer-events: none;
border-radius: 4px;
border-radius: 2px;
}
.indicator.withText {
border-top-left-radius: 0;

View File

@ -37,7 +37,6 @@
let callbackCount = 0
$: visibleIndicators = state.indicators.filter(x => x.visible)
$: offset = $builderStore.inBuilder ? 0 : 2
// Update position when any props change
$: config.set({
@ -150,10 +149,10 @@
const elBounds = child.getBoundingClientRect()
nextState.indicators.push({
top: elBounds.top + scrollY - deviceBounds.top - offset,
left: elBounds.left + scrollX - deviceBounds.left - offset,
width: elBounds.width + 4,
height: elBounds.height + 4,
top: Math.round(elBounds.top + scrollY - deviceBounds.top + 1),
left: Math.round(elBounds.left + scrollX - deviceBounds.left + 1),
width: Math.round(elBounds.width + 2),
height: Math.round(elBounds.height + 2),
visible: false,
insideSidePanel: !!child.closest(".side-panel"),
insideModal: !!child.closest(".modal-content"),

View File

@ -77,8 +77,8 @@ const alignmentToStyleMap = {
stretch: "stretch",
}
export const getBaseGridVars = definition => {
const gridHAlign = definition.grid?.hAlign || "stretch"
const gridVAlign = definition.grid?.vAlign || "center"
const gridHAlign = definition?.grid?.hAlign || "stretch"
const gridVAlign = definition?.grid?.vAlign || "center"
const flexStyles = gridVAlign === "stretch" ? "1 1 0" : "0 0 auto"
return {
["--grid-desktop-h-align"]: alignmentToStyleMap[gridHAlign],