snail.view 1.0.11 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.code-snippets +97 -0
- package/dist/snail.view.d.ts +8 -7
- package/dist/snail.view.js +4 -2
- package/dist/snail.view.umd.js +4 -2
- package/dist/styles/base-mixins.less +58 -2
- package/package.json +2 -2
package/.code-snippets
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// 配合snail库进行less混合代码提示使用的代码片段
|
|
2
|
+
{
|
|
3
|
+
// 引入基础Mixins样式
|
|
4
|
+
"@import-mixins-base": {
|
|
5
|
+
"prefix": "@import-base-mixins",
|
|
6
|
+
"scope": "less",
|
|
7
|
+
"description": "引入基础Mixins样式",
|
|
8
|
+
"body": [
|
|
9
|
+
"// 引入基础Mixins样式",
|
|
10
|
+
"@import \"snail.view/dist/styles/base-mixins.less\";"
|
|
11
|
+
]
|
|
12
|
+
},
|
|
13
|
+
// ***************************************** 👉 文本样式 *****************************************
|
|
14
|
+
"text-ellipsis": {
|
|
15
|
+
"prefix": ".text-ellipsis",
|
|
16
|
+
"scope": "less",
|
|
17
|
+
"description": "文本溢出时出省略号",
|
|
18
|
+
"body": [
|
|
19
|
+
"// 文本溢出时出省略号",
|
|
20
|
+
".text-ellipsis();",
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
// ***************************************** 👉 高宽定位 *****************************************
|
|
24
|
+
"wh-fill": {
|
|
25
|
+
"prefix": ".wh-fill",
|
|
26
|
+
"scope": "less",
|
|
27
|
+
"description": "高度、宽度100%填充满",
|
|
28
|
+
"body": [
|
|
29
|
+
"// width:100%;height:100%",
|
|
30
|
+
".wh-fill();"
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
"wh-fill-hidden": {
|
|
34
|
+
"prefix": ".wh-fill-hidden",
|
|
35
|
+
"scope": "less",
|
|
36
|
+
"description": "高度、宽度100%填充满,隐藏溢出的内容",
|
|
37
|
+
"body": [
|
|
38
|
+
"// width:100%;height:100%;overflow: hidden",
|
|
39
|
+
".wh-fill-hidden();"
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
"left-right-start": {
|
|
43
|
+
"prefix": ".left-right-start",
|
|
44
|
+
"scope": "less",
|
|
45
|
+
"description": "left:0,top:0;辅助 fixed、absolute定位使用",
|
|
46
|
+
"body": [
|
|
47
|
+
"// left、right起始位置:left: 0; top: 0",
|
|
48
|
+
".left-right-start();"
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
"left-right-center": {
|
|
52
|
+
"prefix": ".left-right-center",
|
|
53
|
+
"scope": "less",
|
|
54
|
+
"description": "通过left、rigth进行居中展示:left:50% top:50%; transform: translate(-50%, -50%)",
|
|
55
|
+
"body": [
|
|
56
|
+
"// 通过left、rigth进行居中展示:left:50% top:50%; transform: translate(-50%, -50%)",
|
|
57
|
+
".left-right-center();"
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
// ***************************************** 👉 弹性盒子 *****************************************"
|
|
61
|
+
"flex-main-center": {
|
|
62
|
+
"prefix": ".flex-main-center",
|
|
63
|
+
"scope": "less",
|
|
64
|
+
"description": "flex 布局,主轴居中",
|
|
65
|
+
"body": [
|
|
66
|
+
"// flex 布局:display: flex,justify-content 为center",
|
|
67
|
+
".flex-main-center();"
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
"flex-cross-center": {
|
|
71
|
+
"prefix": ".flex-cross-center",
|
|
72
|
+
"scope": "less",
|
|
73
|
+
"description": "flex 布局,交叉轴居中",
|
|
74
|
+
"body": [
|
|
75
|
+
"// flex 布局:display: flex,align-items 为center",
|
|
76
|
+
".flex-cross-center();"
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
"flex-center": {
|
|
80
|
+
"prefix": ".flex-center",
|
|
81
|
+
"scope": "less",
|
|
82
|
+
"description": "flex 布局,主轴和交叉轴居中",
|
|
83
|
+
"body": [
|
|
84
|
+
"// flex 布局:display: flex,align-items、justify-content 都为center",
|
|
85
|
+
".flex-center();"
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
"flex-right": {
|
|
89
|
+
"prefix": ".flex-right",
|
|
90
|
+
"scope": "less",
|
|
91
|
+
"description": "flex 布局,主轴和交叉轴居右",
|
|
92
|
+
"body": [
|
|
93
|
+
"// flex 布局:display: flex,align-items、justify-content 都为right",
|
|
94
|
+
".flex-right();"
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
}
|
package/dist/snail.view.d.ts
CHANGED
|
@@ -279,7 +279,7 @@ interface IAnimationManager {
|
|
|
279
279
|
* - 开始动画时,清理 to end 操作样式,设置 from 再设异步置 to 样式
|
|
280
280
|
* - 动画结束后,清理 from to 操作样式,保留 end 样式
|
|
281
281
|
* @param el 执行动画的元素
|
|
282
|
-
* @param effect
|
|
282
|
+
* @param effect 过渡效果配置,约束 from to end 样式
|
|
283
283
|
* @param time 动画持续时长,单位ms,默认200ms;动画结束后销毁作用域
|
|
284
284
|
* @returns 动画作用域
|
|
285
285
|
* @example 将div的高度在1s内从100px变为200px。动画结束后保持200px高度,则可以使用如下代码:
|
|
@@ -289,30 +289,31 @@ interface IAnimationManager {
|
|
|
289
289
|
* end: { height: "200px" }
|
|
290
290
|
* }, 1000);
|
|
291
291
|
*/
|
|
292
|
-
transition(el: HTMLElement, effect:
|
|
292
|
+
transition(el: HTMLElement, effect: TransitionEffect<CSS>, time?: number): IScope;
|
|
293
293
|
}
|
|
294
294
|
/**
|
|
295
295
|
* 过渡动画效果配置信息
|
|
296
296
|
* - 执行顺序 from - to - end
|
|
297
|
+
* - 支持泛型,扩展更通用的过渡表述场景
|
|
297
298
|
*/
|
|
298
|
-
type
|
|
299
|
+
type TransitionEffect<T> = {
|
|
299
300
|
/**
|
|
300
301
|
* 过渡动画开始样式
|
|
301
302
|
* - 支持 class 、style 样式属性
|
|
302
303
|
* - 如 高度 从 100 到 200;100 则为动画开始样式
|
|
303
304
|
*/
|
|
304
|
-
from:
|
|
305
|
+
from: T;
|
|
305
306
|
/**
|
|
306
307
|
* 过渡动画目标样式
|
|
307
308
|
* - 支持 class 、style 样式属性
|
|
308
309
|
* - 如 高度 从 100 到 200;200 则为动画目标样式
|
|
309
310
|
*/
|
|
310
|
-
to:
|
|
311
|
+
to: T;
|
|
311
312
|
/**
|
|
312
313
|
* 动画结束样式
|
|
313
314
|
* - 支持 class 、style 样式属性
|
|
314
315
|
*/
|
|
315
|
-
end?:
|
|
316
|
+
end?: T;
|
|
316
317
|
};
|
|
317
318
|
|
|
318
319
|
/**
|
|
@@ -498,4 +499,4 @@ type ElementSize = {
|
|
|
498
499
|
declare function useObserver(): IObserver & IScope;
|
|
499
500
|
|
|
500
501
|
export { configLink, css, link, linkMap, useAnimation, useLink, useObserver };
|
|
501
|
-
export type { AllStyle, BaseStyle, BorderStyle, CSS, CSSDescriptor, ElementSize, FlexBoxStyle, HeightStyle, IAnimationManager, ICSSManager, ILinkManager, IObserver, LinkElement, LinkFile, LinkOptions, MarginStyle, PaddingStyle,
|
|
502
|
+
export type { AllStyle, BaseStyle, BorderStyle, CSS, CSSDescriptor, ElementSize, FlexBoxStyle, HeightStyle, IAnimationManager, ICSSManager, ILinkManager, IObserver, LinkElement, LinkFile, LinkOptions, MarginStyle, PaddingStyle, TransitionEffect, TransitionStyle, WidthStyle };
|
package/dist/snail.view.js
CHANGED
|
@@ -102,12 +102,14 @@ function useAnimation() {
|
|
|
102
102
|
css.operate(el, "clear", toCss);
|
|
103
103
|
css.operate(el, "clear", endCss);
|
|
104
104
|
css.operate(el, "add", fromCss);
|
|
105
|
-
setTimeout(css.operate, 1, el, "add", toCss);
|
|
106
|
-
setTimeout(scope.destroy, time > 0 ? time : 200);
|
|
105
|
+
const toId = setTimeout(css.operate, 1, el, "add", toCss);
|
|
106
|
+
const endId = setTimeout(scope.destroy, time > 0 ? time : 200);
|
|
107
107
|
return scope.onDestroy(function () {
|
|
108
108
|
css.operate(el, "clear", fromCss);
|
|
109
109
|
css.operate(el, "clear", toCss);
|
|
110
110
|
css.operate(el, "add", endCss);
|
|
111
|
+
clearTimeout(toId);
|
|
112
|
+
clearTimeout(endId);
|
|
111
113
|
});
|
|
112
114
|
}
|
|
113
115
|
const manager = mountScope({
|
package/dist/snail.view.umd.js
CHANGED
|
@@ -106,12 +106,14 @@
|
|
|
106
106
|
css.operate(el, "clear", toCss);
|
|
107
107
|
css.operate(el, "clear", endCss);
|
|
108
108
|
css.operate(el, "add", fromCss);
|
|
109
|
-
setTimeout(css.operate, 1, el, "add", toCss);
|
|
110
|
-
setTimeout(scope.destroy, time > 0 ? time : 200);
|
|
109
|
+
const toId = setTimeout(css.operate, 1, el, "add", toCss);
|
|
110
|
+
const endId = setTimeout(scope.destroy, time > 0 ? time : 200);
|
|
111
111
|
return scope.onDestroy(function () {
|
|
112
112
|
css.operate(el, "clear", fromCss);
|
|
113
113
|
css.operate(el, "clear", toCss);
|
|
114
114
|
css.operate(el, "add", endCss);
|
|
115
|
+
clearTimeout(toId);
|
|
116
|
+
clearTimeout(endId);
|
|
115
117
|
});
|
|
116
118
|
}
|
|
117
119
|
const manager = snail_core.mountScope({
|
|
@@ -2,9 +2,65 @@
|
|
|
2
2
|
// 命名规则: .样式信息(如w代表width)-属性(如fill表示填充)()
|
|
3
3
|
// 混入集中的样式统一采用()结尾,避免直接输出;仅作为【定义混入】,不直接参与less样式编译输出
|
|
4
4
|
|
|
5
|
-
// ***************************************** 👉
|
|
6
|
-
//
|
|
5
|
+
// ***************************************** 👉 文本 *****************************************
|
|
6
|
+
// 文本溢出时出省略号
|
|
7
|
+
.text-ellipsis() {
|
|
8
|
+
width: 100%;
|
|
9
|
+
white-space: nowrap;
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
text-overflow: ellipsis;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// ***************************************** 👉 高宽定位 *****************************************
|
|
15
|
+
// 高度、宽度100%填充满
|
|
7
16
|
.wh-fill() {
|
|
8
17
|
width: 100%;
|
|
9
18
|
height: 100%;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// 高度、宽度100%填充满,隐藏溢出的内容
|
|
22
|
+
.wh-fill-hidden() {
|
|
23
|
+
width: 100%;
|
|
24
|
+
height: 100%;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// left、right起始位置:left: 0; top: 0;
|
|
29
|
+
.left-right-start() {
|
|
30
|
+
left: 0;
|
|
31
|
+
top: 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 通过left、rigth进行居中展示:left:50% top:50%; transform: translate(-50%, -50%)
|
|
35
|
+
.left-right-center() {
|
|
36
|
+
left: 50%;
|
|
37
|
+
top: 50%;
|
|
38
|
+
transform: translate(-50%, -50%);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// ***************************************** 👉 弹性盒子 *****************************************
|
|
42
|
+
// flex 布局,主轴居中
|
|
43
|
+
.flex-main-center() {
|
|
44
|
+
display: flex;
|
|
45
|
+
justify-content: center;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// flex 布局,交叉轴居中
|
|
49
|
+
.flex-cross-center() {
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// flex 布局,主轴和交叉轴居中
|
|
55
|
+
.flex-center() {
|
|
56
|
+
display: flex;
|
|
57
|
+
align-items: center;
|
|
58
|
+
justify-content: center;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// flex 布局,主轴和交叉轴居右
|
|
62
|
+
.flex-right() {
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: right;
|
|
65
|
+
justify-content: right;
|
|
10
66
|
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "对视图界面做的一些封装。如样式计算助手方法,常用样式less混入、变量等;dom相关助手类",
|
|
4
4
|
"author": "snail_dev@163.com",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.13",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/snail.view.js",
|
|
9
9
|
"module": "dist/snail.view.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"types": "tsc -p ./tsconfig.dts.json --declarationDir ./dist/_types"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"snail.core": ">=2.0.
|
|
17
|
+
"snail.core": ">=2.0.9"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"rollup": ">=4.39.0",
|