react-sketch-ruler
Version:
> In using react, the zoom operation used for page presentation
131 lines (117 loc) • 2.17 kB
text/less
// 定义变量
@top-bottom-width: 4px;
@left-right-width: 100vw;
@offset: -3px;
@height: 100vh;
@width: 4px;
// 混入定义
.extendable-border(@top-bottom-width: @top-bottom-width, @left-right-width: @left-right-width, @offset: @offset) {
position: absolute;
left: 0;
width: @left-right-width;
&:before,
&:after {
content: '';
display: inline-block;
height: @top-bottom-width;
width: @left-right-width;
position: absolute;
}
&::before {
top: @offset;
left: 0;
}
&::after {
bottom: @offset;
left: 0;
}
}
.vertical-border(@height: @height, @width: @width, @offset: @offset) {
position: absolute;
top: 0;
height: @height;
&:before,
&:after {
content: '';
display: inline-block;
width: @width;
height: @height;
position: absolute;
}
&::before {
left: @offset;
top: 0;
}
&::after {
right: @offset;
top: 0;
}
}
.sketch-ruler {
position: relative;
z-index: 3;
width: 100%;
height: 100%;
overflow: hidden;
font-size: 12px;
span {
line-height: 1;
}
.defaultCursor {
cursor: default ;
}
.grabCursor {
cursor: grab ;
}
.corner {
position: absolute;
top: 0;
left: 0;
pointer-events: auto;
cursor: pointer;
box-sizing: content-box;
transition: all 0.2s ease-in-out;
}
.canvasedit-parent {
position: absolute;
}
.h-container,
.v-container {
position: absolute;
.indicator {
z-index: 4;
position: absolute;
}
.line {
position: absolute;
}
.action {
position: absolute;
}
.value {
transform: scale(0.83);
padding: 5px;
border-radius: 5px;
font-size: 12px;
white-space: nowrap;
}
}
.h-container {
top: 0;
.line {
.vertical-border();
}
.indicator {
.extendable-border();
}
}
.v-container {
left: 0;
.line {
.extendable-border();
}
.indicator {
.vertical-border();
}
}
}