Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
LiveDuo committed Nov 8, 2023
1 parent 5327a5e commit 82599b7
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/client/vanilla/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,19 +291,19 @@ function Editor({ standaloneServer = false }) {
const onCanvasDragOver = (e: React.MouseEvent<HTMLElement>) => {
e.preventDefault()

// get hovered component
const components = getComponents()
components.forEach((c: HTMLDivElement) => {
if (isEventOnElement(c, e)) {
const isTopHalf = isElementTopHalf(c, e)
const component = components.find((c) => isEventOnElement(c, e))!
if (!component) return

c.style.setProperty(`border-${isTopHalf ? 'top' : 'bottom'}`, '4px solid cornflowerblue')
c.style.setProperty(`border-${!isTopHalf ? 'top' : 'bottom'}`, '')
// update border
const isTopHalf = isElementTopHalf(component, e)
component.style.setProperty(`border-${isTopHalf ? 'top' : 'bottom'}`, '4px solid cornflowerblue')
component.style.setProperty(`border-${!isTopHalf ? 'top' : 'bottom'}`, '')

if (!c.isEqualNode(hoveredComponent)) {
setHoveredComponent(c)
}
}
})
// update hovered component
if (component.isEqualNode(hoveredComponent)) return
setHoveredComponent(component)
}

const cleanCanvas = () => {
Expand Down

0 comments on commit 82599b7

Please sign in to comment.