Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions core/src/Tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const ItemTypes = {
export interface TabProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
id: string;
index?: number;
dragableY?: boolean; //Y轴是否可上下拖动
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Amber-Nan 下面注释方法有代码提示

  /** Y轴是否可上下拖动 */
  dragableY?: boolean; 

}

export interface DragItem {
Expand All @@ -20,7 +21,7 @@ export interface DragItem {
type: string;
}

export const Tab: FC<PropsWithChildren<TabProps>> = ({ children, id, index, ...props }) => {
export const Tab: FC<PropsWithChildren<TabProps>> = ({ children, id, index, dragableY = false, ...props }) => {
const { state, onTabClick, onTabDrop, dispatch } = useDataContext();
const ref = useRef<HTMLDivElement>(null);
const [{ handlerId }, drop] = useDrop<DragItem, void, { handlerId: Identifier | null }>({
Expand Down Expand Up @@ -53,7 +54,7 @@ export const Tab: FC<PropsWithChildren<TabProps>> = ({ children, id, index, ...p
// When dragging downwards, only move when the cursor is below 50%
// When dragging upwards, only move when the cursor is above 50%
// Dragging downwards
if (dragIndex < hoverIndex && hoverClientX < hoverMiddleX) {
if (dragIndex < hoverIndex && hoverClientX < hoverMiddleX && dragableY !== true) {
return;
}
// Dragging upwards
Expand Down