@ajaxjs/ui 1.1.6 → 1.1.8

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.
@@ -1,125 +1,125 @@
1
- <template>
2
- <ul class="aj-opacity-banner">
3
- <slot></slot>
4
- </ul>
5
- </template>
6
-
7
- <script lang="ts">
8
- /**
9
- * 渐显 banner
10
- * 注意:定时器保存在 DOM 元素的属性上,是否会内存泄漏呢?
11
- */
12
- export default {
13
- props: {
14
- delay: { default: 3000 }, // 延时
15
- fps: { default: 25 }, // 帧速
16
- },
17
- data(): any {
18
- return {
19
- active: 0, // 当前索引
20
- };
21
- },
22
- mounted(): void {
23
- this.list = this.$el.querySelectorAll("li"); // 各帧
24
- this.list[0].style.opacity = "1";
25
- this.run();
26
- },
27
- methods: {
28
- /**
29
- * 播放动画
30
- *
31
- * @param this
32
- */
33
- run(): void {
34
- this.timer = window.setInterval(() => {
35
- let active: number = this.active;
36
- this.clear();
37
- active += 1;
38
- this.active = active % this.list.length;
39
- this.animate(100);
40
- }, this.delay);
41
- },
42
-
43
- /**
44
- * 下一帧
45
- *
46
- * @param this
47
- */
48
- per(): void {
49
- let active: number = this.active;
50
- this.clear();
51
- active -= 1;
52
- active = active % this.list.length;
53
-
54
- if (active < 0) active = this.list.length - 1;
55
-
56
- this.active = active;
57
- this.animate(100);
58
- },
59
-
60
- /**
61
- * 内容淡出
62
- */
63
- clear(): void {
64
- this.animate(0);
65
- },
66
-
67
- /**
68
- *
69
- * @param params
70
- */
71
- animate(params: number): void {
72
- var el: HTMLLIElement = this.list[this.active],
73
- fps: number = 1000 / this.fps;
74
- // @ts-ignore
75
- window.clearTimeout(el.timer);
76
-
77
- window.setTimeout(function loop() {
78
- var i: number = getOpacity(el);
79
- let speed: number = (params - i) / 8;
80
- speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed);
81
- // console.log("i=" + i + "; speed="+ speed+"; s="+s+"; k="+k);
82
- i += speed;
83
- el.style.opacity = String(i / 100);
84
- // @ts-ignore
85
- window.clearTimeout(el.timer);
86
- // params.complete && params.complete.call(elem);
87
- // @ts-ignore
88
- el.timer = window.setTimeout(loop, fps);
89
- }, fps);
90
- },
91
- },
92
- };
93
-
94
- /**
95
- * 获取元素的透明度
96
- *
97
- * @param el
98
- */
99
- function getOpacity(el: Element): number {
100
- let v = Number(getComputedStyle(el)["opacity"]);
101
- v *= 100;
102
-
103
- return parseFloat(v + "") || 0;
104
- }
105
- </script>
106
-
107
- <style lang="less" scoped>
108
- .aj-opacity-banner {
109
- position: relative;
110
- min-height: 90px;
111
-
112
- li {
113
- position: absolute;
114
- top: 0;
115
- left: 0;
116
- opacity: 0;
117
- width: 100%;
118
- }
119
-
120
- img {
121
- // border-top:solid 20px #00416d;
122
- width: 100%;
123
- }
124
- }
1
+ <template>
2
+ <ul class="aj-opacity-banner">
3
+ <slot></slot>
4
+ </ul>
5
+ </template>
6
+
7
+ <script lang="ts">
8
+ /**
9
+ * 渐显 banner
10
+ * 注意:定时器保存在 DOM 元素的属性上,是否会内存泄漏呢?
11
+ */
12
+ export default {
13
+ props: {
14
+ delay: { default: 3000 }, // 延时
15
+ fps: { default: 25 }, // 帧速
16
+ },
17
+ data(): any {
18
+ return {
19
+ active: 0, // 当前索引
20
+ };
21
+ },
22
+ mounted(): void {
23
+ this.list = this.$el.querySelectorAll("li"); // 各帧
24
+ this.list[0].style.opacity = "1";
25
+ this.run();
26
+ },
27
+ methods: {
28
+ /**
29
+ * 播放动画
30
+ *
31
+ * @param this
32
+ */
33
+ run(): void {
34
+ this.timer = window.setInterval(() => {
35
+ let active: number = this.active;
36
+ this.clear();
37
+ active += 1;
38
+ this.active = active % this.list.length;
39
+ this.animate(100);
40
+ }, this.delay);
41
+ },
42
+
43
+ /**
44
+ * 下一帧
45
+ *
46
+ * @param this
47
+ */
48
+ per(): void {
49
+ let active: number = this.active;
50
+ this.clear();
51
+ active -= 1;
52
+ active = active % this.list.length;
53
+
54
+ if (active < 0) active = this.list.length - 1;
55
+
56
+ this.active = active;
57
+ this.animate(100);
58
+ },
59
+
60
+ /**
61
+ * 内容淡出
62
+ */
63
+ clear(): void {
64
+ this.animate(0);
65
+ },
66
+
67
+ /**
68
+ *
69
+ * @param params
70
+ */
71
+ animate(params: number): void {
72
+ var el: HTMLLIElement = this.list[this.active],
73
+ fps: number = 1000 / this.fps;
74
+ // @ts-ignore
75
+ window.clearTimeout(el.timer);
76
+
77
+ window.setTimeout(function loop() {
78
+ var i: number = getOpacity(el);
79
+ let speed: number = (params - i) / 8;
80
+ speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed);
81
+ // console.log("i=" + i + "; speed="+ speed+"; s="+s+"; k="+k);
82
+ i += speed;
83
+ el.style.opacity = String(i / 100);
84
+ // @ts-ignore
85
+ window.clearTimeout(el.timer);
86
+ // params.complete && params.complete.call(elem);
87
+ // @ts-ignore
88
+ el.timer = window.setTimeout(loop, fps);
89
+ }, fps);
90
+ },
91
+ },
92
+ };
93
+
94
+ /**
95
+ * 获取元素的透明度
96
+ *
97
+ * @param el
98
+ */
99
+ function getOpacity(el: Element): number {
100
+ let v = Number(getComputedStyle(el)["opacity"]);
101
+ v *= 100;
102
+
103
+ return parseFloat(v + "") || 0;
104
+ }
105
+ </script>
106
+
107
+ <style lang="less" scoped>
108
+ .aj-opacity-banner {
109
+ position: relative;
110
+ min-height: 90px;
111
+
112
+ li {
113
+ position: absolute;
114
+ top: 0;
115
+ left: 0;
116
+ opacity: 0;
117
+ width: 100%;
118
+ }
119
+
120
+ img {
121
+ // border-top:solid 20px #00416d;
122
+ width: 100%;
123
+ }
124
+ }
125
125
  </style>
@@ -1,133 +1,133 @@
1
- <template>
2
- <div class="aj-process-line">
3
- <div class="process-line">
4
- <div v-for="(item, index) in items" :key="index" :class="{current: index == current, done: index < current}">
5
- <span>{{index + 1}}</span>
6
- <p>{{item}}</p>
7
- </div>
8
- </div>
9
- </div>
10
- </template>
11
-
12
- <script lang="ts">
13
- /**
14
- * 进度条
15
- */
16
- export default {
17
- props: {
18
- items: {
19
- type: Array,
20
- default(): string[] {
21
- return ["Step 1", "Step 2", "Step 3"];
22
- },
23
- },
24
- },
25
- data():any {
26
- return {
27
- current: 0,
28
- };
29
- },
30
- methods: {
31
- /**
32
- *
33
- * @param i
34
- */
35
- go(i: number): void {
36
- this.current = i;
37
- },
38
-
39
- /**
40
- *
41
- */
42
- perv(): void {
43
- let perv: number = this.current - 1;
44
- if (perv < 0) perv = this.items.length - 1;
45
-
46
- this.go(perv);
47
- },
48
-
49
- /**
50
- *
51
- */
52
- next(): void {
53
- let next: number = this.current + 1;
54
- if (this.items.length == next) next = 0; // 循环
55
-
56
- this.go(next);
57
- },
58
- },
59
- };
60
- </script>
61
-
62
- <style lang="less" scoped>
63
- .aj-process-line {
64
- display: flex;
65
- padding: 5%;
66
- justify-content: center;
67
-
68
- .process-line {
69
- font-size: 18px;
70
- color: lightgray;
71
- font-weight: bold;
72
-
73
- & > div {
74
- float: left;
75
- width: 156px;
76
- text-align: center;
77
- position: relative;
78
-
79
- &.current {
80
- color: black;
81
-
82
- span {
83
- background-color: gray;
84
- }
85
- }
86
-
87
- &.done {
88
- // color: lighten(@mainColor, 80%);
89
- span {
90
- // background-color: lighten(@mainColor, 50%);
91
- }
92
-
93
- &::after {
94
- // background-color: lighten(@mainColor, 50%);
95
- }
96
- }
97
-
98
- p {
99
- font-size: 1rem;
100
- letter-spacing: 3px;
101
- padding-top: 5%;
102
- }
103
-
104
- span {
105
- display: inline-block;
106
- width: 32px;
107
- height: 32px;
108
- border-radius: 50%;
109
- color: #fff;
110
- line-height: 32px;
111
- font-size: 16px;
112
- background-color: lightgray;
113
- position: relative;
114
- z-index: 1;
115
- }
116
-
117
- &:last-child::after {
118
- display: none;
119
- }
120
-
121
- &::after {
122
- content: "";
123
- position: absolute;
124
- top: 14px;
125
- left: 94px;
126
- width: 124px;
127
- height: 4px;
128
- background-color: lightgray;
129
- }
130
- }
131
- }
132
- }
1
+ <template>
2
+ <div class="aj-process-line">
3
+ <div class="process-line">
4
+ <div v-for="(item, index) in items" :key="index" :class="{current: index == current, done: index < current}">
5
+ <span>{{index + 1}}</span>
6
+ <p>{{item}}</p>
7
+ </div>
8
+ </div>
9
+ </div>
10
+ </template>
11
+
12
+ <script lang="ts">
13
+ /**
14
+ * 进度条
15
+ */
16
+ export default {
17
+ props: {
18
+ items: {
19
+ type: Array,
20
+ default(): string[] {
21
+ return ["Step 1", "Step 2", "Step 3"];
22
+ },
23
+ },
24
+ },
25
+ data():any {
26
+ return {
27
+ current: 0,
28
+ };
29
+ },
30
+ methods: {
31
+ /**
32
+ *
33
+ * @param i
34
+ */
35
+ go(i: number): void {
36
+ this.current = i;
37
+ },
38
+
39
+ /**
40
+ *
41
+ */
42
+ perv(): void {
43
+ let perv: number = this.current - 1;
44
+ if (perv < 0) perv = this.items.length - 1;
45
+
46
+ this.go(perv);
47
+ },
48
+
49
+ /**
50
+ *
51
+ */
52
+ next(): void {
53
+ let next: number = this.current + 1;
54
+ if (this.items.length == next) next = 0; // 循环
55
+
56
+ this.go(next);
57
+ },
58
+ },
59
+ };
60
+ </script>
61
+
62
+ <style lang="less" scoped>
63
+ .aj-process-line {
64
+ display: flex;
65
+ padding: 5%;
66
+ justify-content: center;
67
+
68
+ .process-line {
69
+ font-size: 18px;
70
+ color: lightgray;
71
+ font-weight: bold;
72
+
73
+ & > div {
74
+ float: left;
75
+ width: 156px;
76
+ text-align: center;
77
+ position: relative;
78
+
79
+ &.current {
80
+ color: black;
81
+
82
+ span {
83
+ background-color: gray;
84
+ }
85
+ }
86
+
87
+ &.done {
88
+ // color: lighten(@mainColor, 80%);
89
+ span {
90
+ // background-color: lighten(@mainColor, 50%);
91
+ }
92
+
93
+ &::after {
94
+ // background-color: lighten(@mainColor, 50%);
95
+ }
96
+ }
97
+
98
+ p {
99
+ font-size: 1rem;
100
+ letter-spacing: 3px;
101
+ padding-top: 5%;
102
+ }
103
+
104
+ span {
105
+ display: inline-block;
106
+ width: 32px;
107
+ height: 32px;
108
+ border-radius: 50%;
109
+ color: #fff;
110
+ line-height: 32px;
111
+ font-size: 16px;
112
+ background-color: lightgray;
113
+ position: relative;
114
+ z-index: 1;
115
+ }
116
+
117
+ &:last-child::after {
118
+ display: none;
119
+ }
120
+
121
+ &::after {
122
+ content: "";
123
+ position: absolute;
124
+ top: 14px;
125
+ left: 94px;
126
+ width: 124px;
127
+ height: 4px;
128
+ background-color: lightgray;
129
+ }
130
+ }
131
+ }
132
+ }
133
133
  </style>