Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
DoraemonKit
提交
9d75b586
D
DoraemonKit
项目概览
DiDi
/
DoraemonKit
10 个月 前同步成功
通知
166
Star
19623
Fork
3062
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DoraemonKit
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
9d75b586
编写于
6月 01, 2021
作者:
B
BinTang
提交者:
GitHub
6月 01, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add Align Ruler for Web (#833)
上级
1ba14467
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
314 addition
and
6 deletion
+314
-6
Web/packages/web/src/feature.js
Web/packages/web/src/feature.js
+3
-6
Web/packages/web/src/plugins/align-ruler/align-ruler.vue
Web/packages/web/src/plugins/align-ruler/align-ruler.vue
+230
-0
Web/packages/web/src/plugins/align-ruler/index.js
Web/packages/web/src/plugins/align-ruler/index.js
+16
-0
Web/packages/web/src/plugins/align-ruler/info-box.vue
Web/packages/web/src/plugins/align-ruler/info-box.vue
+65
-0
未找到文件。
Web/packages/web/src/feature.js
浏览文件 @
9d75b586
...
...
@@ -4,6 +4,7 @@ import Storage from './plugins/storage/index'
import
DemoPlugin
from
'
./plugins/demo-plugin/index
'
import
DemoIndependPlugin
from
'
./plugins/demo-single-plugin/index
'
import
H5DoorPlugin
from
'
./plugins/h5-door/index
'
import
AlignRuler
from
'
./plugins/align-ruler/index
'
import
HelloWorld
from
'
./components/ToolHelloWorld
'
import
Resource
from
'
./plugins/resources/index
'
import
{
IndependPlugin
,
RouterPlugin
}
from
'
@dokit/web-core
'
...
...
@@ -25,12 +26,8 @@ export const DokitFeatures = {
export
const
UIFeatures
=
{
title
:
'
视觉功能
'
,
list
:
[
new
RouterPlugin
({
nameZh
:
'
对齐标尺
'
,
name
:
'
align-ruler
'
,
icon
:
'
https://pt-starimg.didistatic.com/static/starimg/img/a5UTjMn6lO1618997535798.png
'
,
component
:
HelloWorld
}),
new
RouterPlugin
({
list
:
[
AlignRuler
,
new
RouterPlugin
({
nameZh
:
'
UI结构
'
,
name
:
'
view-selector
'
,
icon
:
'
https://pt-starimg.didistatic.com/static/starimg/img/XNViIWzG7N1618997548483.png
'
,
...
...
Web/packages/web/src/plugins/align-ruler/align-ruler.vue
0 → 100644
浏览文件 @
9d75b586
<
template
>
<div>
<div
class=
"ruler-center-bg"
:style=
"centerStyle"
></div>
<div
class=
"ruler-center-round"
:style=
"centerStyle"
></div>
<div
class=
"ruler-center-dot"
:style=
"centerStyle"
></div>
<div
class=
"ruler-line ruler-horizon-line"
:style=
"horizonLineStyle"
></div>
<div
class=
"ruler-line ruler-vertical-line"
:style=
"verticalLineStyle"
></div>
<div
class=
"ruler-info"
:style=
"topInfoStyle"
>
{{
position
.
top
}}
</div>
<div
class=
"ruler-info"
:style=
"rightInfoStyle"
>
{{
position
.
right
}}
</div>
<div
class=
"ruler-info"
:style=
"bottomInfoStyle"
>
{{
position
.
bottom
}}
</div>
<div
class=
"ruler-info"
:style=
"leftInfoStyle"
>
{{
position
.
left
}}
</div>
<InfoBox
:position=
"position"
@
remove=
"remove"
/>
<div
class=
"ruler-drag-mask"
:style=
"centerStyle"
@
mousedown=
"drag"
@
touchstart=
"drag"
></div>
</div>
</
template
>
<
script
>
import
InfoBox
from
"
./info-box
"
;
import
{
removeIndependPlugin
}
from
"
@dokit/web-core
"
;
export
default
{
name
:
"
align-ruler
"
,
components
:
{
InfoBox
,
},
data
()
{
return
{
posX
:
200
,
posY
:
200
,
screenWidth
:
document
.
documentElement
.
clientWidth
,
screenHeight
:
document
.
documentElement
.
clientHeight
,
};
},
computed
:
{
position
()
{
return
{
top
:
this
.
posY
,
left
:
this
.
posX
,
right
:
this
.
screenWidth
-
this
.
posX
,
bottom
:
this
.
screenHeight
-
this
.
posY
,
};
},
centerStyle
()
{
return
{
top
:
this
.
posY
+
"
px
"
,
left
:
this
.
posX
+
"
px
"
,
};
},
horizonLineStyle
()
{
return
{
width
:
this
.
screenWidth
+
"
px
"
,
top
:
this
.
posY
+
"
px
"
,
};
},
verticalLineStyle
()
{
return
{
height
:
this
.
screenHeight
+
"
px
"
,
left
:
this
.
posX
+
"
px
"
,
};
},
topInfoStyle
()
{
return
{
top
:
this
.
posY
/
2
+
"
px
"
,
left
:
this
.
posX
+
"
px
"
,
};
},
rightInfoStyle
()
{
return
{
top
:
this
.
posY
+
"
px
"
,
left
:
(
this
.
posX
+
this
.
screenWidth
)
/
2
+
"
px
"
,
};
},
bottomInfoStyle
()
{
return
{
top
:
(
this
.
screenHeight
+
this
.
posY
)
/
2
+
"
px
"
,
left
:
this
.
posX
+
"
px
"
,
};
},
leftInfoStyle
()
{
return
{
top
:
this
.
posY
+
"
px
"
,
left
:
this
.
posX
/
2
+
"
px
"
,
};
},
},
// 监听浏览器缩放
mounted
()
{
window
.
addEventListener
(
"
resize
"
,
this
.
handleResize
);
},
beforeUnmount
()
{
window
.
removeEventListener
(
"
resize
"
,
this
.
handleResize
);
},
methods
:
{
remove
()
{
removeIndependPlugin
(
"
align-ruler
"
);
},
handleResize
(
event
)
{
this
.
screenWidth
=
document
.
documentElement
.
clientWidth
;
this
.
screenHeight
=
document
.
documentElement
.
clientHeight
;
this
.
posX
=
this
.
screenWidth
*
0.3
;
this
.
posY
=
this
.
screenHeight
*
0.3
;
},
drag
(
e
)
{
e
.
preventDefault
();
e
.
stopPropagation
();
let
el
=
e
.
target
;
// 算出鼠标相对元素的位置
// 兼容触摸和鼠标
let
startX
=
e
.
clientX
?
e
.
clientX
:
e
.
touches
[
0
].
clientX
;
let
startY
=
e
.
clientY
?
e
.
clientY
:
e
.
touches
[
0
].
clientY
;
let
offsetX
=
startX
-
el
.
offsetLeft
;
let
offsetY
=
startY
-
el
.
offsetTop
;
let
update
=
(
X
,
Y
)
=>
{
let
left
=
X
-
offsetX
;
let
top
=
Y
-
offsetY
;
this
.
posX
=
Math
.
round
(
left
);
this
.
posY
=
Math
.
round
(
top
);
};
let
handleMousemove
=
(
e
)
=>
{
update
(
e
.
clientX
,
e
.
clientY
);
};
let
handleTouchmove
=
(
e
)
=>
{
update
(
e
.
touches
[
0
].
clientX
,
e
.
touches
[
0
].
clientY
);
};
let
removeDragHandle
=
(
e
)
=>
{
document
.
removeEventListener
(
"
mousemove
"
,
handleMousemove
);
document
.
removeEventListener
(
"
touchmove
"
,
handleTouchmove
);
document
.
removeEventListener
(
"
mouseup
"
,
removeDragHandle
);
document
.
removeEventListener
(
"
touchend
"
,
removeDragHandle
);
};
document
.
addEventListener
(
"
mousemove
"
,
handleMousemove
);
document
.
addEventListener
(
"
touchmove
"
,
handleTouchmove
);
document
.
addEventListener
(
"
mouseup
"
,
removeDragHandle
);
document
.
addEventListener
(
"
touchend
"
,
removeDragHandle
);
},
},
};
</
script
>
<
style
scoped
>
.color
{
color
:
#ffffff
;
color
:
#cc3a4b
;
color
:
#337cc4
;
color
:
#cc3a4b30
;
}
.ruler-center-bg
{
box-sizing
:
border-box
;
background-color
:
rgba
(
255
,
255
,
255
,
0.392156863
);
position
:
fixed
;
width
:
60px
;
height
:
60px
;
transform
:
translate
(
-30px
,
-30px
);
border-radius
:
30px
;
border
:
solid
1px
rgba
(
51
,
124
,
196
,
0.392156863
);
}
.ruler-center-round
{
background-color
:
rgba
(
204
,
58
,
75
,
0.196078431
);
position
:
fixed
;
width
:
40px
;
height
:
40px
;
transform
:
translate
(
-20px
,
-20px
);
border-radius
:
20px
;
}
.ruler-center-dot
{
background-color
:
#cc3a4b
;
position
:
fixed
;
width
:
6px
;
height
:
6px
;
transform
:
translate
(
-3px
,
-3px
);
border-radius
:
3px
;
}
.ruler-line
{
position
:
fixed
;
background-color
:
#cc3a4b
;
}
.ruler-horizon-line
{
left
:
0
;
height
:
1px
;
transform
:
translate
(
0px
,
-0.5px
);
}
.ruler-vertical-line
{
top
:
0
;
width
:
1px
;
transform
:
translate
(
-0.5px
,
0px
);
}
.ruler-info
{
position
:
fixed
;
}
.ruler-drag-mask
{
position
:
fixed
;
width
:
60px
;
height
:
60px
;
transform
:
translate
(
-30px
,
-30px
);
border-radius
:
30px
;
}
</
style
>
Web/packages/web/src/plugins/align-ruler/index.js
0 → 100644
浏览文件 @
9d75b586
//
// 功能: 对齐标尺
// 作者: foolbit (唐斌)
// 时间v2021-5-30
//
import
AlignRuler
from
'
./align-ruler.vue
'
import
{
IndependPlugin
}
from
'
@dokit/web-core
'
export
default
new
IndependPlugin
({
nameZh
:
'
对齐标尺
'
,
name
:
'
align-ruler
'
,
icon
:
'
https://pt-starimg.didistatic.com/static/starimg/img/a5UTjMn6lO1618997535798.png
'
,
component
:
AlignRuler
})
Web/packages/web/src/plugins/align-ruler/info-box.vue
0 → 100644
浏览文件 @
9d75b586
<
template
>
<div
class=
"position-infobox-container"
>
位置: 左
{{
position
.
left
}}
, 右
{{
position
.
right
}}
, 上
{{
position
.
top
}}
, 下
{{
position
.
bottom
}}
<span
class=
"close-button"
@
click=
"$emit('remove')"
></span>
</div>
</
template
>
<
script
>
export
default
{
props
:
{
position
:
{
top
:
0
,
right
:
0
,
bottom
:
0
,
left
:
0
,
},
},
};
</
script
>
<
style
scoped
>
.position-infobox-container
{
position
:
fixed
;
left
:
0
;
right
:
0
;
margin
:
auto
;
bottom
:
20px
;
width
:
250px
;
height
:
50px
;
padding
:
0px
20px
;
line-height
:
50px
;
font-size
:
12px
;
border-radius
:
5px
;
box-shadow
:
0px
0px
2px
#cccccc
;
}
.position-info
{
font-size
:
10px
;
}
.close-button
{
background
:
#324456
;
color
:
#fff
;
border-radius
:
10px
;
width
:
20px
;
height
:
20px
;
line-height
:
18px
;
font-size
:
15px
;
text-align
:
center
;
top
:
15px
;
right
:
10px
;
position
:
absolute
;
}
.close-button
::before
{
content
:
"×"
;
}
</
style
>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录