|
@@ -2,7 +2,6 @@ import { useCallback, useEffect, useRef, useState } from 'react'
|
|
|
import { flushSync } from 'react-dom'
|
|
import { flushSync } from 'react-dom'
|
|
|
import { useReviewPanelUpdaterFnsContext } from '../../../context/review-panel/review-panel-context'
|
|
import { useReviewPanelUpdaterFnsContext } from '../../../context/review-panel/review-panel-context'
|
|
|
import { useLayoutContext } from '../../../../../shared/context/layout-context'
|
|
import { useLayoutContext } from '../../../../../shared/context/layout-context'
|
|
|
-import useScopeValue from '../../../../../shared/hooks/use-scope-value'
|
|
|
|
|
import EntryIndicator from '../entries/entry-indicator'
|
|
import EntryIndicator from '../entries/entry-indicator'
|
|
|
|
|
|
|
|
export type Coordinates = {
|
|
export type Coordinates = {
|
|
@@ -12,7 +11,6 @@ export type Coordinates = {
|
|
|
|
|
|
|
|
function useIndicatorHover() {
|
|
function useIndicatorHover() {
|
|
|
const [hoverCoords, setHoverCoords] = useState<Coordinates | null>(null)
|
|
const [hoverCoords, setHoverCoords] = useState<Coordinates | null>(null)
|
|
|
- const [layoutToLeft] = useScopeValue<boolean>('reviewPanel.layoutToLeft')
|
|
|
|
|
const { toggleReviewPanel } = useReviewPanelUpdaterFnsContext()
|
|
const { toggleReviewPanel } = useReviewPanelUpdaterFnsContext()
|
|
|
const { reviewPanelOpen } = useLayoutContext()
|
|
const { reviewPanelOpen } = useLayoutContext()
|
|
|
const { setLayoutSuspended, handleLayoutChange } =
|
|
const { setLayoutSuspended, handleLayoutChange } =
|
|
@@ -22,7 +20,7 @@ function useIndicatorHover() {
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
const endHover = useCallback(() => {
|
|
const endHover = useCallback(() => {
|
|
|
- if (!reviewPanelOpen && !layoutToLeft) {
|
|
|
|
|
|
|
+ if (!reviewPanelOpen) {
|
|
|
// Use flushSync to ensure that React renders immediately. This is
|
|
// Use flushSync to ensure that React renders immediately. This is
|
|
|
// necessary to ensure that the subsequent layout update acts on the
|
|
// necessary to ensure that the subsequent layout update acts on the
|
|
|
// updated DOM.
|
|
// updated DOM.
|
|
@@ -32,17 +30,15 @@ function useIndicatorHover() {
|
|
|
})
|
|
})
|
|
|
handleLayoutChange({ force: true })
|
|
handleLayoutChange({ force: true })
|
|
|
}
|
|
}
|
|
|
- }, [handleLayoutChange, layoutToLeft, reviewPanelOpen, setLayoutSuspended])
|
|
|
|
|
|
|
+ }, [handleLayoutChange, reviewPanelOpen, setLayoutSuspended])
|
|
|
|
|
|
|
|
const handleIndicatorMouseEnter = () => {
|
|
const handleIndicatorMouseEnter = () => {
|
|
|
- if (!layoutToLeft) {
|
|
|
|
|
- const rect = indicatorRef.current?.getBoundingClientRect()
|
|
|
|
|
- setHoverCoords({
|
|
|
|
|
- x: rect?.left || 0,
|
|
|
|
|
- y: rect?.top || 0,
|
|
|
|
|
- })
|
|
|
|
|
- setLayoutSuspended(true)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ const rect = indicatorRef.current?.getBoundingClientRect()
|
|
|
|
|
+ setHoverCoords({
|
|
|
|
|
+ x: rect?.left || 0,
|
|
|
|
|
+ y: rect?.top || 0,
|
|
|
|
|
+ })
|
|
|
|
|
+ setLayoutSuspended(true)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const handleIndicatorClick = () => {
|
|
const handleIndicatorClick = () => {
|