Skip to content

Commit e7b3df7

Browse files
Amber-Nan杨楠
andauthored
feat: add dragableY props. (#11)
* feat:新增Y周是否可拖动参数及判断 * fix:修改参数为驼峰 * fix:修改y轴拖动参数名称 --------- Co-authored-by: 杨楠 <yangnan@ane56.com>
1 parent 5bd0adb commit e7b3df7

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

core/src/Tab.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const ItemTypes = {
1212
export interface TabProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
1313
id: string;
1414
index?: number;
15+
dragableY?: boolean; //Y轴是否可上下拖动
1516
}
1617

1718
export interface DragItem {
@@ -20,7 +21,7 @@ export interface DragItem {
2021
type: string;
2122
}
2223

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

0 commit comments

Comments
 (0)