Skip to content

Commit

Permalink
fix: drag treenode style
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjinzhou committed Jan 23, 2022
1 parent d442db0 commit 6d4248d
Showing 1 changed file with 61 additions and 13 deletions.
74 changes: 61 additions & 13 deletions components/tree/style/mixin.less
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@import '../../style/mixins/index';

@tree-prefix-cls: ~'@{ant-prefix}-tree';
@tree-node-prefix-cls: ~'@{tree-prefix-cls}-treenode';
@select-tree-prefix-cls: ~'@{ant-prefix}-select-tree';
@tree-motion: ~'@{ant-prefix}-motion-collapse';
@tree-node-padding: (@padding-xs / 2);
Expand All @@ -13,6 +12,7 @@
display: inline-block;
font-size: 10px;
vertical-align: baseline;

svg {
transition: transform 0.3s;
}
Expand All @@ -28,6 +28,7 @@
background-color: @primary-color;
border-radius: 1px;
pointer-events: none;

&::after {
position: absolute;
top: -3px;
Expand Down Expand Up @@ -66,6 +67,26 @@
.@{custom-tree-prefix-cls}-node-content-wrapper {
flex: auto;
}

// >>> Drag
.@{custom-tree-node-prefix-cls}.dragging {
position: relative;

&::after {
position: absolute;
top: 0;
right: 0;
bottom: @tree-node-padding;
left: 0;
border: 1px solid @primary-color;
opacity: 0;
animation: ant-tree-node-fx-do-not-use 0.3s;
animation-play-state: running;
animation-fill-mode: forwards;
content: '';
pointer-events: none;
}
}
}
}

Expand Down Expand Up @@ -110,6 +131,19 @@
}
}

// >>> Drag Handler
&-draggable-icon {
width: @tree-title-height;
line-height: @tree-title-height;
text-align: center;
opacity: 0.2;
transition: opacity @animation-duration-slow;

.@{custom-tree-node-prefix-cls}:hover & {
opacity: 0.45;
}
}

// >>> Switcher
&-switcher {
.antTreeSwitcherIcon();
Expand Down Expand Up @@ -145,19 +179,21 @@
display: inline-block;
width: 100%;
height: 100%;
// https://github.com/ant-design/ant-design/issues/31884
&::before {
position: absolute;
top: 0;
right: 12px;
bottom: -@tree-node-padding;
margin-left: -1px;
border-left: 1px solid @normal-color;
border-right: 1px solid @normal-color;
content: ' ';
}

&::after {
position: absolute;
width: @tree-title-height - 14px;
height: @tree-title-height - 10px;
margin-left: -1px;
border-bottom: 1px solid @normal-color;
content: ' ';
}
Expand Down Expand Up @@ -200,6 +236,7 @@
line-height: @tree-title-height;
text-align: center;
vertical-align: top;

&:empty {
display: none;
}
Expand All @@ -212,7 +249,7 @@
}

// ==================== Draggable =====================
&-node-content-wrapper[draggable='true'] {
&-node-content-wrapper {
line-height: @tree-title-height;
user-select: none;

Expand Down Expand Up @@ -255,20 +292,31 @@
background: @component-background;

&-line-icon {
vertical-align: -0.225em;
// https://github.com/ant-design/ant-design/issues/32813
vertical-align: -0.15em;
}
}
}
}

.@{tree-node-prefix-cls}-leaf-last {
.@{tree-prefix-cls}-switcher {
&-leaf-line {
&::before {
top: auto !important;
bottom: auto !important;
height: @tree-title-height - 10px !important;
.@{custom-tree-node-prefix-cls}-leaf-last {
.@{custom-tree-prefix-cls}-switcher {
&-leaf-line {
&::before {
top: auto !important;
bottom: auto !important;
height: @tree-title-height - 10px !important;
}
}
}
}
}

@keyframes ant-tree-node-fx-do-not-use {
0% {
opacity: 0;
}

100% {
opacity: 1;
}
}

0 comments on commit 6d4248d

Please sign in to comment.