fix production issue
This commit is contained in:
@@ -45,36 +45,37 @@ export function HomepageLayoutEditor({ layout, availableSections, onChange, onAd
|
||||
|
||||
useEffect(() => {
|
||||
if (!interaction) return
|
||||
const snap = interaction
|
||||
|
||||
function handlePointerMove(event: PointerEvent) {
|
||||
const canvas = canvasRef.current
|
||||
if (!canvas) return
|
||||
const rect = canvas.getBoundingClientRect()
|
||||
const colWidth = rect.width / PUBLIC_HOMEPAGE_GRID_COLUMNS
|
||||
const deltaCols = Math.round((event.clientX - interaction.startX) / colWidth)
|
||||
const deltaRows = Math.round((event.clientY - interaction.startY) / ROW_HEIGHT)
|
||||
const limits = getPublicHomepageSectionLimits(interaction.origin.type)
|
||||
const deltaCols = Math.round((event.clientX - snap.startX) / colWidth)
|
||||
const deltaRows = Math.round((event.clientY - snap.startY) / ROW_HEIGHT)
|
||||
const limits = getPublicHomepageSectionLimits(snap.origin.type)
|
||||
|
||||
onChange({
|
||||
items: layout.items.map((item) => {
|
||||
if (item.id !== interaction.itemId) return item
|
||||
if (interaction.mode === 'move') {
|
||||
if (item.id !== snap.itemId) return item
|
||||
if (snap.mode === 'move') {
|
||||
return {
|
||||
...item,
|
||||
x: clamp(interaction.origin.x + deltaCols, 1, PUBLIC_HOMEPAGE_GRID_COLUMNS - interaction.origin.w + 1),
|
||||
y: clamp(interaction.origin.y + deltaRows, 1, PUBLIC_HOMEPAGE_GRID_ROWS - interaction.origin.h + 1),
|
||||
x: clamp(snap.origin.x + deltaCols, 1, PUBLIC_HOMEPAGE_GRID_COLUMNS - snap.origin.w + 1),
|
||||
y: clamp(snap.origin.y + deltaRows, 1, PUBLIC_HOMEPAGE_GRID_ROWS - snap.origin.h + 1),
|
||||
}
|
||||
}
|
||||
|
||||
const nextW = clamp(
|
||||
interaction.origin.w + deltaCols,
|
||||
snap.origin.w + deltaCols,
|
||||
limits.minW,
|
||||
Math.min(limits.maxW, PUBLIC_HOMEPAGE_GRID_COLUMNS - interaction.origin.x + 1),
|
||||
Math.min(limits.maxW, PUBLIC_HOMEPAGE_GRID_COLUMNS - snap.origin.x + 1),
|
||||
)
|
||||
const nextH = clamp(
|
||||
interaction.origin.h + deltaRows,
|
||||
snap.origin.h + deltaRows,
|
||||
limits.minH,
|
||||
Math.min(limits.maxH, PUBLIC_HOMEPAGE_GRID_ROWS - interaction.origin.y + 1),
|
||||
Math.min(limits.maxH, PUBLIC_HOMEPAGE_GRID_ROWS - snap.origin.y + 1),
|
||||
)
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user