Skip to content

Commit

Permalink
* dtable: optimize UI for sorting cols by dnd.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed Jul 29, 2024
1 parent 568eb27 commit bb2633c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/dtable/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ onPageUpdate(() => {
const customColsTable = new DTable('#customColsTable', {
cols: [
{name: 'id', title: 'ID', width: 80, fixed: 'left', sortType: 'desc', checkbox: true},
{name: 'name', title: '项目名称', minWidth: 200, flex: 1, sortType: true, nestedToggle: true, childLabel: '子'},
{name: 'name', title: '项目名称', minWidth: 200, fixed: 'left', flex: 1, sortType: true, nestedToggle: true, childLabel: '子'},
{name: 'manager', title: '负责人', sortType: true, border: true, width: 200},
{name: 'storyScale', title: '需求规模', sortType: true},
{name: 'executionCount', title: '执行数', sortType: true},
Expand Down
10 changes: 3 additions & 7 deletions lib/dtable/src/plugins/sort-col/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,21 +173,17 @@ const sortColPlugin: DTableSorColPlugin = {
return;
}

const {from, element, offset} = sortColInfo;
const {from, element} = sortColInfo;
const $cells = $(element).closest('.dtable-cells');
const bounding = $cells[0]!.getBoundingClientRect();
const width = bounding.width;
const pos = event.clientX - bounding.left - offset;
if ((pos + from.width) < 0 || (pos - from.width) > width) {
return sortColInfo.state;
}
const pos = event.clientX - bounding.left;
const {cols, scrollLeft} = this.layout;
const sideCols = cols[from.side].list;
if (sideCols.length <= 1) {
return sortColInfo.state;
}
const left = scrollLeft + pos;
const to = sideCols.find(col => col.name !== from.name && col.visible && col.left <= left && (col.left + col.width) > left);
const to = sideCols.find(col => col.visible && col.left <= left && (col.left + col.width) > left);
if (!to) {
return sortColInfo.state;
}
Expand Down

0 comments on commit bb2633c

Please sign in to comment.