Skip to content

Commit

Permalink
Merge pull request #116 from nikolas-con/main
Browse files Browse the repository at this point in the history
Fixed flickering
  • Loading branch information
LiveDuo authored Mar 12, 2024
2 parents 0bb10b7 + 6f78950 commit 6632e0b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/client/vanilla/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,10 @@ function Editor({ standaloneServer = false }) {

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

// update hovered component
if (component.isEqualNode(hoveredComponent)) return
Expand All @@ -320,15 +322,15 @@ function Editor({ standaloneServer = false }) {
const removeBorders = () => {
const components = getComponents()
components.forEach((c: HTMLDivElement) => {
c.style.setProperty('border-top', '')
c.style.setProperty('border-bottom', '')
c.style.setProperty('box-shadow', '')
})
}

// NOTE this trigger more times than it should
const onCanvasDragLeave = () => {
setHoveredComponent(null)
removeBorders()
const onCanvasDragLeave = (e: React.DragEvent<HTMLElement>) => {
if (!canvasRef.current?.contains(e.target as HTMLElement)) {
setHoveredComponent(null)
removeBorders()
}
}

const getComponents = (): HTMLDivElement[] => {
Expand Down

0 comments on commit 6632e0b

Please sign in to comment.