diff --git a/src/components/column/card.tsx b/src/components/column/card.tsx index 40c3a19..8f5ff84 100644 --- a/src/components/column/card.tsx +++ b/src/components/column/card.tsx @@ -41,7 +41,8 @@ export const CardWrapper = forwardRef(({ id, isDragg
(({ id, isDragg ) }) -export function CardOverlay({ id }: { id: SourceID }) { - return ( -
-
-
-
- - - - {sources[id].name} - - {sources[id]?.title && {sources[id].title}} - - 拖拽中 - -
-
-
-
-
-
- ) -} - function NewsCard({ id, inView, handleListeners }: NewsCardProps) { const [focusSources, setFocusSources] = useAtom(focusSourcesAtom) const [refetchSource, setRefetchSource] = useAtom(refetchSourcesAtom) @@ -136,9 +99,9 @@ function NewsCard({ id, inView, handleListeners }: NewsCardProps) {
@@ -148,7 +111,7 @@ function NewsCard({ id, inView, handleListeners }: NewsCardProps) { {sources[id]?.title && {sources[id].title}} - +
@@ -179,8 +142,9 @@ function NewsCard({ id, inView, handleListeners }: NewsCardProps) { options={{ overflow: { x: "hidden" }, }} + defer > -
+
{sources[id].type === "hottest" ? : }
diff --git a/src/components/column/dnd.tsx b/src/components/column/dnd.tsx index 4907377..6478785 100644 --- a/src/components/column/dnd.tsx +++ b/src/components/column/dnd.tsx @@ -8,6 +8,7 @@ import { MouseSensor, TouchSensor, closestCenter, + defaultDropAnimationSideEffects, useSensor, useSensors, } from "@dnd-kit/core" @@ -17,8 +18,10 @@ import { useAtom } from "jotai" import type { SourceID } from "@shared/types" import { CSS } from "@dnd-kit/utilities" import { motion } from "framer-motion" +import { sources } from "@shared/sources" +import clsx from "clsx" import type { ItemsProps } from "./card" -import { CardOverlay, CardWrapper } from "./card" +import { CardWrapper } from "./card" import { currentSourcesAtom } from "~/atoms" export function Dnd() { @@ -35,8 +38,8 @@ export function Dnd() { variants={{ visible: { transition: { - delayChildren: 0.3, - staggerChildren: 0.2, + delayChildren: 0.2, + staggerChildren: 0.1, }, }, }} @@ -65,13 +68,7 @@ interface DndProps { setItems: (update: SourceID[]) => void } -const measuringConfig = { - droppable: { - strategy: MeasuringStrategy.Always, - }, -} - -export function DndWrapper({ items, setItems, children }: PropsWithChildren) { +function DndWrapper({ items, setItems, children }: PropsWithChildren) { const [activeId, setActiveId] = useState(null) const sensors = useSensors(useSensor(MouseSensor), useSensor(TouchSensor)) @@ -97,7 +94,11 @@ export function DndWrapper({ items, setItems, children }: PropsWithChildren - {/* {!!activeId && } */} - + {!!activeId && } ) } +function CardOverlay({ id }: { id: SourceID }) { + return ( +
+
+
+
+ + + + {sources[id].name} + + {sources[id]?.title && {sources[id].title}} + + 拖拽中 + +
+
+
+
+
+ ) +} + const animateLayoutChanges: AnimateLayoutChanges = (args) => { const { isSorting, wasDragging } = args if (isSorting || wasDragging) { diff --git a/src/components/common/overlay-scrollbar.tsx b/src/components/common/overlay-scrollbar.tsx index 3993318..26e036b 100644 --- a/src/components/common/overlay-scrollbar.tsx +++ b/src/components/common/overlay-scrollbar.tsx @@ -16,7 +16,7 @@ const defaultScrollbarParams: UseOverlayScrollbarsParams = { defer: true, } -export function OverlayScrollbar({ children, options, events, defer, ...props }: PropsWithChildren) { +export function OverlayScrollbar({ disabled, children, options, events, defer, ...props }: PropsWithChildren) { const ref = useRef(null) const scrollbarParams = useMemo(() => defu >({ options, @@ -27,14 +27,16 @@ export function OverlayScrollbar({ children, options, events, defer, ...props }: const [initialize] = useOverlayScrollbars(scrollbarParams) useEffect(() => { - initialize({ - target: ref.current!, - cancel: { + if (!disabled) { + initialize({ + target: ref.current!, + cancel: { // 如果浏览器原生滚动条是覆盖在元素上的,则取消初始化 - nativeScrollbarsOverlaid: true, - }, - }) - }, [initialize]) + nativeScrollbarsOverlaid: true, + }, + }) + } + }, [initialize, disabled]) return (
@@ -75,7 +77,7 @@ export function GlobalOverlayScrollbar({ children, ...props }: PropsWithChildren events: { scroll: (_, e) => onScroll(e), }, - defer: true, + defer: false, }) useEffect(() => {