vdesign-ui 0.2.4 → 0.2.6

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.
Files changed (195) hide show
  1. package/package.json +1 -1
  2. package/dist/components/actionbar/index.js +0 -8
  3. package/dist/components/actionbar/index.vue +0 -39
  4. package/dist/components/actionbar/style.less +0 -44
  5. package/dist/components/actionbar-cell/index.js +0 -7
  6. package/dist/components/actionbar-cell/index.vue +0 -38
  7. package/dist/components/actions/index.js +0 -7
  8. package/dist/components/actions/index.vue +0 -76
  9. package/dist/components/actions/style.less +0 -109
  10. package/dist/components/actions-cell/index.js +0 -7
  11. package/dist/components/actions-cell/index.vue +0 -94
  12. package/dist/components/actions-cell/style.less +0 -39
  13. package/dist/components/activityviews/index.js +0 -8
  14. package/dist/components/activityviews/index.vue +0 -192
  15. package/dist/components/activityviews/style.less +0 -152
  16. package/dist/components/badge/index.js +0 -8
  17. package/dist/components/badge/index.vue +0 -49
  18. package/dist/components/badge/style.less +0 -54
  19. package/dist/components/button/index.js +0 -8
  20. package/dist/components/button/index.vue +0 -93
  21. package/dist/components/button/style.less +0 -558
  22. package/dist/components/calendar/end.png +0 -0
  23. package/dist/components/calendar/index-element.vue +0 -84
  24. package/dist/components/calendar/index.js +0 -8
  25. package/dist/components/calendar/index.vue +0 -52
  26. package/dist/components/calendar/start.png +0 -0
  27. package/dist/components/calendar/style.less +0 -138
  28. package/dist/components/checkbox/index.js +0 -8
  29. package/dist/components/checkbox/index.vue +0 -161
  30. package/dist/components/checkbox/style.less +0 -289
  31. package/dist/components/checkbox-group/index.js +0 -7
  32. package/dist/components/checkbox-group/index.vue +0 -69
  33. package/dist/components/common/state/index.vue +0 -33
  34. package/dist/components/common/state/style.less +0 -48
  35. package/dist/components/data-list/index.js +0 -10
  36. package/dist/components/data-list/index.vue +0 -19
  37. package/dist/components/data-list/style.less +0 -623
  38. package/dist/components/datetime-picker/index.js +0 -8
  39. package/dist/components/datetime-picker/index.vue +0 -37
  40. package/dist/components/datetime-picker/style.less +0 -24
  41. package/dist/components/dialog/index.js +0 -8
  42. package/dist/components/dialog/index.vue +0 -174
  43. package/dist/components/dialog/overlay-manager.js +0 -18
  44. package/dist/components/dialog/style.less +0 -128
  45. package/dist/components/divider/index.js +0 -8
  46. package/dist/components/divider/index.vue +0 -54
  47. package/dist/components/divider/style.less +0 -92
  48. package/dist/components/dropdown/index.js +0 -8
  49. package/dist/components/dropdown/index.vue +0 -218
  50. package/dist/components/dropdown/style.less +0 -432
  51. package/dist/components/empty/404-dark.png +0 -0
  52. package/dist/components/empty/404.png +0 -0
  53. package/dist/components/empty/index.js +0 -8
  54. package/dist/components/empty/index.vue +0 -138
  55. package/dist/components/empty/network-dark.png +0 -0
  56. package/dist/components/empty/network.png +0 -0
  57. package/dist/components/empty/nocoupons-dark.png +0 -0
  58. package/dist/components/empty/nocoupons.png +0 -0
  59. package/dist/components/empty/nodata-dark.png +0 -0
  60. package/dist/components/empty/nodata.png +0 -0
  61. package/dist/components/empty/nomargin-dark.png +0 -0
  62. package/dist/components/empty/nomargin.png +0 -0
  63. package/dist/components/empty/nonotice-dark.png +0 -0
  64. package/dist/components/empty/nonotice.png +0 -0
  65. package/dist/components/empty/noocomments-dark.png +0 -0
  66. package/dist/components/empty/noocomments.png +0 -0
  67. package/dist/components/empty/noorders-dark.png +0 -0
  68. package/dist/components/empty/noorders.png +0 -0
  69. package/dist/components/empty/noposition-dark.png +0 -0
  70. package/dist/components/empty/noposition.png +0 -0
  71. package/dist/components/empty/nosearch-dark.png +0 -0
  72. package/dist/components/empty/nosearch.png +0 -0
  73. package/dist/components/empty/style.less +0 -61
  74. package/dist/components/footer/index.js +0 -7
  75. package/dist/components/footer/index.vue +0 -33
  76. package/dist/components/footer/style.less +0 -21
  77. package/dist/components/footnav/index.js +0 -7
  78. package/dist/components/footnav/index.vue +0 -93
  79. package/dist/components/footnav/style.less +0 -23
  80. package/dist/components/footnav-item/index.js +0 -7
  81. package/dist/components/footnav-item/index.vue +0 -50
  82. package/dist/components/footnav-item/style.less +0 -39
  83. package/dist/components/form/index.js +0 -7
  84. package/dist/components/form/index.vue +0 -12
  85. package/dist/components/headnav/index.js +0 -7
  86. package/dist/components/headnav/index.vue +0 -185
  87. package/dist/components/headnav/style.less +0 -232
  88. package/dist/components/icon/font/iconfont.css +0 -159
  89. package/dist/components/icon/font/iconfont.js +0 -6
  90. package/dist/components/icon/index.js +0 -9
  91. package/dist/components/icon/index.vue +0 -54
  92. package/dist/components/icon/style.less +0 -44
  93. package/dist/components/input/calcTextareaHeight.js +0 -162
  94. package/dist/components/input/index.js +0 -8
  95. package/dist/components/input/index.vue +0 -345
  96. package/dist/components/input/style.less +0 -471
  97. package/dist/components/list/index.js +0 -8
  98. package/dist/components/list/index.vue +0 -152
  99. package/dist/components/list/style.less +0 -213
  100. package/dist/components/loading/index.js +0 -7
  101. package/dist/components/loading/index.vue +0 -68
  102. package/dist/components/loading/style.less +0 -54
  103. package/dist/components/mixins/clickoutside.js +0 -81
  104. package/dist/components/mixins/dom.js +0 -41
  105. package/dist/components/mixins/languageMixin.js +0 -41
  106. package/dist/components/mixins/outlineConfigPlugin.js +0 -45
  107. package/dist/components/mixins/router-link.js +0 -23
  108. package/dist/components/mixins/themeMixin.js +0 -43
  109. package/dist/components/noticebar/index.js +0 -8
  110. package/dist/components/noticebar/index.vue +0 -258
  111. package/dist/components/noticebar/style.less +0 -328
  112. package/dist/components/overlay/index.js +0 -8
  113. package/dist/components/overlay/index.vue +0 -184
  114. package/dist/components/overlay/style.less +0 -23
  115. package/dist/components/pagebreak/index.js +0 -7
  116. package/dist/components/pagebreak/index.vue +0 -67
  117. package/dist/components/pagebreak/style.less +0 -42
  118. package/dist/components/password/index.js +0 -8
  119. package/dist/components/password/index.vue +0 -60
  120. package/dist/components/popover/index.js +0 -8
  121. package/dist/components/popover/index.vue +0 -100
  122. package/dist/components/popover/style.less +0 -346
  123. package/dist/components/popover/vue-popover.vue +0 -314
  124. package/dist/components/popup/index.js +0 -7
  125. package/dist/components/popup/index.vue +0 -243
  126. package/dist/components/radio/index.js +0 -8
  127. package/dist/components/radio/index.vue +0 -184
  128. package/dist/components/radio/style.less +0 -294
  129. package/dist/components/radio-group/index.js +0 -6
  130. package/dist/components/radio-group/index.vue +0 -58
  131. package/dist/components/result/completed-dark.png +0 -0
  132. package/dist/components/result/completed.png +0 -0
  133. package/dist/components/result/error-dark.png +0 -0
  134. package/dist/components/result/error.png +0 -0
  135. package/dist/components/result/index.js +0 -8
  136. package/dist/components/result/index.vue +0 -73
  137. package/dist/components/result/style.less +0 -44
  138. package/dist/components/result/wait-dark.png +0 -0
  139. package/dist/components/result/wait.png +0 -0
  140. package/dist/components/search/index.js +0 -8
  141. package/dist/components/search/index.vue +0 -66
  142. package/dist/components/selector/index.js +0 -8
  143. package/dist/components/selector/index.vue +0 -161
  144. package/dist/components/selector/style.less +0 -484
  145. package/dist/components/skeleton/index.js +0 -7
  146. package/dist/components/skeleton/index.vue +0 -206
  147. package/dist/components/skeleton/style.less +0 -197
  148. package/dist/components/slider/draggable.js +0 -49
  149. package/dist/components/slider/index.js +0 -7
  150. package/dist/components/slider/index.vue +0 -167
  151. package/dist/components/slider/style.less +0 -100
  152. package/dist/components/slider/utils.js +0 -60
  153. package/dist/components/step/index.js +0 -7
  154. package/dist/components/step/index.vue +0 -48
  155. package/dist/components/step/style.less +0 -58
  156. package/dist/components/step-item/index.js +0 -7
  157. package/dist/components/step-item/index.vue +0 -126
  158. package/dist/components/step-item/style.less +0 -362
  159. package/dist/components/stepper/index.js +0 -8
  160. package/dist/components/stepper/index.vue +0 -146
  161. package/dist/components/style/index.vue +0 -42
  162. package/dist/components/switch/index.js +0 -8
  163. package/dist/components/switch/index.vue +0 -72
  164. package/dist/components/switch/style.less +0 -56
  165. package/dist/components/tab/index.js +0 -7
  166. package/dist/components/tab/index.vue +0 -53
  167. package/dist/components/tabs/index.js +0 -8
  168. package/dist/components/tabs/index.vue +0 -172
  169. package/dist/components/tabs/style.less +0 -377
  170. package/dist/components/tag/index.js +0 -7
  171. package/dist/components/tag/index.vue +0 -64
  172. package/dist/components/tag/style.less +0 -211
  173. package/dist/components/title/index.js +0 -8
  174. package/dist/components/title/index.vue +0 -99
  175. package/dist/components/title/style.less +0 -188
  176. package/dist/components/toast/index.js +0 -86
  177. package/dist/components/toast/index.vue +0 -44
  178. package/dist/components/toast/style.less +0 -55
  179. package/dist/components/transition/index.js +0 -8
  180. package/dist/components/transition/index.vue +0 -13
  181. package/dist/components/transition/style.less +0 -208
  182. package/dist/components/upload/index.js +0 -7
  183. package/dist/components/upload/index.vue +0 -106
  184. package/dist/components/upload/style.less +0 -147
  185. package/dist/components/utils/assist.js +0 -34
  186. package/dist/components/utils/env.js +0 -2
  187. package/dist/demo.html +0 -10
  188. package/dist/locale/ar.js +0 -98
  189. package/dist/locale/en.js +0 -98
  190. package/dist/locale/zh.js +0 -98
  191. package/dist/token.css +0 -2990
  192. package/dist/vdesign-ui.common.js +0 -27471
  193. package/dist/vdesign-ui.css +0 -1
  194. package/dist/vdesign-ui.umd.js +0 -27481
  195. package/dist/vdesign-ui.umd.min.js +0 -32
@@ -1,206 +0,0 @@
1
- <script>
2
- const prefixCls = 'vd-skeleton';
3
- export default {
4
- name: 'vd-skeleton',
5
- props: {
6
- row: {
7
- type: Number,
8
- default: 4,
9
- },
10
- img: {
11
- type: Boolean,
12
- },
13
- title: {
14
- type: [Boolean, String],
15
- default: false,
16
- validator: (value) => {
17
- return typeof value === 'boolean' || ['s', 'm', 'l'].includes(value);
18
- },
19
- },
20
- button: {
21
- type: Boolean,
22
- },
23
- paragraph: {
24
- type: Boolean,
25
- },
26
- sImg: {
27
- type: Boolean,
28
- },
29
- avatar: {
30
- type: [Boolean, String],
31
- default: false,
32
- validator: (value) => {
33
- return typeof value === 'boolean' || ['s', 'm', 'l'].includes(value);
34
- },
35
- },
36
- text: {
37
- type: Boolean,
38
- },
39
- stock: {
40
- type: Boolean,
41
- },
42
- data: {
43
- type: Boolean,
44
- },
45
- equally: {
46
- type: Boolean,
47
- },
48
- equallys: {
49
- type: Number,
50
- default: 2,
51
- },
52
- height: {
53
- type: Number,
54
- },
55
- animate: {
56
- type: Boolean,
57
- default: true,
58
- },
59
- loading: {
60
- type: Boolean,
61
- default: true,
62
- },
63
- },
64
- computed: {
65
- titleClasses() {
66
- let size = 's'; // 默认尺寸
67
- if (typeof this.title === 'string' && ['s', 'm', 'l'].includes(this.title)) {
68
- size = this.title;
69
- }
70
- return {
71
- [`${prefixCls}__title--${size}`]: true,
72
- };
73
- },
74
- avatarClasses() {
75
- let size = 's'; // 默认尺寸
76
- if (typeof this.avatar === 'string' && ['s', 'm', 'l'].includes(this.avatar)) {
77
- size = this.avatar;
78
- }
79
- return {
80
- [`${prefixCls}__avatar--${size}`]: true,
81
- };
82
- },
83
- },
84
- render(h) {
85
- if (this.loading) {
86
- return h(
87
- 'div',
88
- {
89
- class: [prefixCls, { [`${prefixCls}--animate`]: this.animate }],
90
- },
91
- [
92
- // 图片占位符
93
- this.img ? h('div', { class: `${prefixCls}__img` }) : null,
94
- // 标题占位符
95
- this.title
96
- ? h('div', {
97
- class: [`${prefixCls}__title`, this.titleClasses],
98
- })
99
- : null,
100
- // 按钮占位符
101
- this.button ? h('div', { class: `${prefixCls}__button` }) : null,
102
- // 小图片占位符
103
- this.sImg ? h('div', { class: `${prefixCls}__img--s` }) : null,
104
- // 头像占位符
105
- this.avatar
106
- ? h('div', {
107
- class: [`${prefixCls}__avatar`, this.avatarClasses],
108
- })
109
- : null,
110
- // 段落和文本占位符
111
- (this.paragraph || this.text)
112
- ? h(
113
- 'div',
114
- { class: `${prefixCls}__content` },
115
- [
116
- this.text ? h('div', { class: `${prefixCls}__text` }) : null,
117
- this.paragraph
118
- ? Array.from({ length: this.row }).map((_, index) =>
119
- h('div', {
120
- key: index,
121
- class: [
122
- `${prefixCls}__paragraph`,
123
- {
124
- 'is-last':
125
- index === this.row - 1 && this.row > 1,
126
- },
127
- ],
128
- })
129
- )
130
- : null,
131
- ].filter(Boolean)
132
- )
133
- : null,
134
- // 股票占位符
135
- this.stock
136
- ? h('div', { class: `${prefixCls}__stock` }, [
137
- h('div', { class: `${prefixCls}__stock--left` }, [
138
- h('span', { class: `${prefixCls}__stock--data` }),
139
- h('span', { class: `${prefixCls}__stock--subdatax` }),
140
- ]),
141
- h('div', { class: `${prefixCls}--space` }, [
142
- h('div', { class: `${prefixCls}__stock--center` }),
143
- h(
144
- 'div',
145
- {
146
- class: [`${prefixCls}__stock--right`, 'spacing'],
147
- },
148
- [
149
- h('span', { class: `${prefixCls}__stock--title` }),
150
- h('span', { class: `${prefixCls}__stock--text` }),
151
- ]
152
- ),
153
- ]),
154
- ])
155
- : null,
156
- // 数据占位符
157
- this.data
158
- ? h('div', { class: `${prefixCls}__stock` }, [
159
- h('div', { class: `${prefixCls}__stock--left` }, [
160
- h('span', { class: `${prefixCls}__stock--data` }),
161
- h('span', { class: `${prefixCls}__stock--subdatal` }),
162
- ]),
163
- h('div', { class: `${prefixCls}--space` }, [
164
- h('div', { class: `${prefixCls}__stock--right` }, [
165
- h('span', { class: `${prefixCls}__stock--title` }),
166
- h('span', { class: `${prefixCls}__stock--text` }),
167
- ]),
168
- h('div', { class: `${prefixCls}__stock--right` }, [
169
- h('span', { class: `${prefixCls}__stock--title` }),
170
- h('span', { class: `${prefixCls}__stock--text` }),
171
- ]),
172
- h('div', { class: `${prefixCls}__stock--right` }, [
173
- h('span', { class: `${prefixCls}__stock--title` }),
174
- h('span', { class: `${prefixCls}__stock--text` }),
175
- ]),
176
- ]),
177
- ])
178
- : null,
179
- // 等分占位符
180
- this.equally
181
- ? h(
182
- 'div',
183
- { class: `${prefixCls}__equally` },
184
- Array.from({ length: this.equallys }).map((_, index) =>
185
- h('div', {
186
- key: index,
187
- class: `${prefixCls}__img`,
188
- style: { height: `${this.height}px` },
189
- })
190
- )
191
- )
192
- : null,
193
- ].filter(Boolean)
194
- );
195
- } else {
196
- // 返回插槽内容
197
- return this.$slots.default ? this.$slots.default : null;
198
- }
199
- },
200
- };
201
- </script>
202
-
203
- <style lang="less">
204
- @import './style.less';
205
-
206
- </style>
@@ -1,197 +0,0 @@
1
- @skeleton-prefix-cls: vd-skeleton;
2
-
3
- .@{skeleton-prefix-cls} {
4
- display: flex;
5
- padding: 0 var(--spacing-base-loose);
6
-
7
- &__img, &__title, &__button, &__img--s, &__paragraph, &__avatar, &__text,
8
- &__stock--data, &__stock--subdatax, &__stock--subdatal, &__stock--center, &__stock--title,
9
- &__stock--text, &__stock--content, &__stock--maindata {
10
- background: var(--color-skeleton-bg);
11
- }
12
-
13
- &--animate &__img, &__title, &__button, &__img--s, &__paragraph, &__avatar, &__text,
14
- &__stock--data, &__stock--subdatax, &__stock--subdatal, &__stock--center, &__stock--title,
15
- &__stock--text, &__stock--content, &__stock--maindata {
16
- background: linear-gradient(
17
- 90deg,
18
- var(--color-skeleton-bg) 25%,
19
- var(--color-skeleton-loading_gradient-bg-active) 44%,
20
- var(--color-skeleton-bg) 88%
21
- );
22
- background-size: 400% 100%;
23
- animation: skeleton-loading 1.4s ease infinite;
24
- animation-fill-mode: forwards;
25
- }
26
-
27
- &__img {
28
- width: 100%;
29
- height: var(--height-skeleton-img);
30
- border-radius: var(--radius-skeleton-img);
31
- }
32
-
33
- &__title {
34
- width: var(--width-skeleton-head);
35
-
36
- &--l {
37
- height: var(--height-skeleton-text_l);
38
- border-radius: var(--radius-skeleton-text_l);
39
- }
40
- &--m {
41
- height: var(--height-skeleton-text_m);
42
- border-radius: var(--radius-skeleton-text_s);
43
- }
44
- &--s {
45
- height: var(--height-skeleton-text_s);
46
- border-radius: var(--radius-skeleton-text_s);
47
- }
48
- }
49
-
50
- &__button {
51
- width: var(--width-skeleton-button);
52
- height: var(--height-skeleton-button);
53
- border-radius: var(--radius-skeleton-button);
54
- }
55
-
56
- &__img--s {
57
- width: var(--width-skeleton-img_small);
58
- height: var(--height-skeleton-small_shapes);
59
- border-radius: var(--radius-skeleton-small_shapes);
60
- }
61
-
62
- &__content {
63
- width: 100%;
64
- .is-last {
65
- width: 80%;
66
- margin-block-end: 0;
67
- }
68
- }
69
-
70
- &__paragraph {
71
- width: 100%;
72
- height: var(--height-skeleton-text_s);
73
- margin-block-end: var(--spacing-skeleton-text-margin_bottom);
74
- border-radius: var(--radius-skeleton-text_s);
75
- }
76
-
77
- &__avatar {
78
- flex-shrink: 0;
79
- border-radius: 50%;
80
- margin-inline-end: var(--spacing-skeleton-avatar-margin_right);
81
-
82
- &--l {
83
- width: var(--width-skeleton-avatar_l);
84
- height: var(--width-skeleton-avatar_l);
85
- }
86
- &--m {
87
- width: var(--width-skeleton-avatar_m);
88
- height: var(--width-skeleton-avatar_m);
89
- }
90
- &--s {
91
- width: var(--width-skeleton-avatar_s);
92
- height: var(--width-skeleton-avatar_s);
93
- }
94
- }
95
-
96
- &__text {
97
- margin: var(--spacing-skeleton-avatar-margin_bottom) 0;
98
- width: var(--width-skeleton-avatar_text);
99
- height: var(--height-skeleton-text_m);
100
- border-radius: var(--radius-skeleton-text_s);
101
- }
102
-
103
- &__stock {
104
- width: 100%;
105
- display: flex;
106
- justify-content: space-between;
107
-
108
- &--left {
109
- display: flex;
110
- flex-direction: column;
111
- }
112
- &--data {
113
- width: var(--width-skeleton-stock_data_s);
114
- height: var(--height-skeleton-text_m);
115
- border-radius: var(--radius-skeleton-text_s);
116
- }
117
- &--subdatax {
118
- margin-block-start: var(--spacing-skeleton-stock-padding_x);
119
- width: var(--width-skeleton-stock_data_xl);
120
- height: var(--height-skeleton-text_s);
121
- border-radius: var(--radius-skeleton-text_s);
122
- }
123
- &--subdatal {
124
- margin-block-start: var(--spacing-skeleton-stock-padding_x);
125
- width: var(--width-skeleton-stock_data_l);
126
- height: var(--height-skeleton-text_s);
127
- border-radius: var(--radius-skeleton-text_s);
128
- }
129
- &--center {
130
- width: var(--width-skeleton-stock_data_m);
131
- height: var(--height-skeleton-text_l);
132
- border-radius: var(--radius-skeleton-text_s);
133
- }
134
- &--right {
135
- margin-inline-start: var(--spacing-skeleton-data-padding_y);
136
- display: flex;
137
- align-items: flex-end;
138
- flex-direction: column;
139
- }
140
- &--title {
141
- width: var(--width-skeleton-stock_data_l);
142
- height: var(--height-skeleton-text_m);
143
- border-radius: var(--radius-skeleton-text_s);
144
- }
145
- &--text {
146
- margin-block-start: var(--spacing-skeleton-stock-padding_x);
147
- width: var(--width-skeleton-stock_data_s);
148
- height: var(--height-skeleton-text_s);
149
- border-radius: var(--radius-skeleton-text_s);
150
- }
151
- &--content {
152
- display: flex;
153
- align-items: flex-end;
154
- flex-direction: column;
155
- }
156
- &--maindata {
157
- width: var(--width-skeleton-stock_data_m);
158
- height: var(--height-skeleton-text_m);
159
- border-radius: var(--radius-skeleton-text_s);
160
- }
161
- }
162
-
163
- &--space {
164
- display: flex;
165
- align-items: center;
166
-
167
- .spacing {
168
- margin-inline-start: var(--spacing-skeleton-stock-padding_y);
169
- }
170
- }
171
-
172
- &__equally {
173
- display: flex;
174
- width: 100%;
175
- gap: var(--spacing-skeleton-avatar-margin_right);
176
- }
177
- }
178
-
179
- @keyframes skeleton-loading {
180
- 0% {
181
- background-position: 100% 50%;
182
- }
183
- 100% {
184
- background-position: 0 50%;
185
- }
186
- }
187
-
188
-
189
- @keyframes skeleton-loading {
190
- 0%{
191
- background-position: 100% 50%;
192
- }
193
-
194
- 100% {
195
- background-position: 0 50%;
196
- }
197
- }
@@ -1,49 +0,0 @@
1
- let isDragging = false;
2
- import Vue from 'vue';
3
- const supportTouch = !Vue.prototype.$isServer && 'ontouchstart' in window;
4
-
5
- export default function(element, options) {
6
- const moveFn = function(event) {
7
- if (options.drag) {
8
- options.drag(supportTouch ? event.changedTouches[0] || event.touches[0] : event);
9
- }
10
- };
11
-
12
- const endFn = function(event) {
13
- if (!supportTouch) {
14
- document.removeEventListener('mousemove', moveFn);
15
- document.removeEventListener('mouseup', endFn);
16
- }
17
- document.onselectstart = null;
18
- document.ondragstart = null;
19
-
20
- isDragging = false;
21
-
22
- if (options.end) {
23
- options.end(supportTouch ? event.changedTouches[0] || event.touches[0] : event);
24
- }
25
- };
26
-
27
- element.addEventListener(supportTouch ? 'touchstart' : 'mousedown', function(event) {
28
- if (isDragging) return;
29
- event.preventDefault();
30
- document.onselectstart = function() { return false; };
31
- document.ondragstart = function() { return false; };
32
-
33
- if (!supportTouch) {
34
- document.addEventListener('mousemove', moveFn);
35
- document.addEventListener('mouseup', endFn);
36
- }
37
- isDragging = true;
38
-
39
- if (options.start) {
40
- options.start(supportTouch ? event.changedTouches[0] || event.touches[0] : event);
41
- }
42
- });
43
-
44
- if (supportTouch) {
45
- element.addEventListener('touchmove', moveFn);
46
- element.addEventListener('touchend', endFn);
47
- element.addEventListener('touchcancel', endFn);
48
- }
49
- }
@@ -1,7 +0,0 @@
1
- import Slider from './index.vue';
2
- import './style.less';
3
- Slider.install = function(Vue) {
4
- Vue.component(Slider.name, Slider)
5
- }
6
-
7
- export default Slider;
@@ -1,167 +0,0 @@
1
- <template>
2
- <div class="vd-slider">
3
- <template v-if="demonstration">
4
- <div class="vd-slider__marks vd-slider__marks--top">
5
- <div class="vd-slider__marks--start" :class="{ 'vd-slider__marks--hidden': (showMarks && progress === 0) }">0%
6
- </div>
7
- <div class="vd-slider__marks--end" v-if="progressWidth < 100">100%</div>
8
- </div>
9
- <div class="vd-slider__wrap vd-slider__wrap--demonstration" ref="content">
10
- <div class="vd-slider__bar vd-slider__bar--demonstration" :style="{ width: progressWidth + '%' }"></div>
11
- <div class="vd-slider__button vd-slider__button--demonstration" ref="thumb"
12
- :class="{ 'vd-slider__button--active': progress }" :style="{left: this.progress + '%'}">
13
- <!-- 显示逻辑是滑动时候显示 -->
14
- <span class="vd-slider__tips" v-if="showMarks">{{ value }}%</span>
15
- </div>
16
- <template v-for="(item, index) in items">
17
- <div :key="index" v-if="index > 1 && index !== items.length - 1"
18
- :class="['vd-slider__dots', { 'vd-slider__dots--active': (index - 1) % 2 !== 0 }]"
19
- :style="{ left: (index - 1) * 5 + '%' }"></div>
20
- </template>
21
- </div>
22
- </template>
23
- <template v-else>
24
- <div class="vd-slider__wrap" ref="content">
25
- <div class="vd-slider__bar" :style="{ width: progressWidth + '%' }"></div>
26
- <div class="vd-slider__button" :class="{ 'vd-slider__button--active': progress }" ref="thumb"
27
- :style="{left: this.progress + '%'}">
28
- </div>
29
- </div>
30
- <div class="vd-slider__marks">
31
- <div class="vd-slider__marks--start">0%</div>
32
- <div class="vd-slider__marks--end">100%</div>
33
- </div>
34
- </template>
35
- </div>
36
- </template>
37
-
38
- <script>
39
- import languageMixin from '../mixins/languageMixin.js';
40
-
41
- import draggable from './draggable';
42
- export default {
43
- name: 'vd-slider',
44
- mixins: [languageMixin],
45
- props: {
46
- demonstration: {
47
- type: Boolean,
48
- default: false
49
- },
50
- min: {
51
- type: Number,
52
- default: 0
53
- },
54
- max: {
55
- type: Number,
56
- default: 100
57
- },
58
- step: {
59
- type: Number,
60
- default: 1
61
- },
62
- value: {
63
- type: Number
64
- },
65
-
66
- },
67
- data() {
68
- return {
69
- items: Array(22),
70
- showMarks: false, // 控制是否显示百分比标记
71
- hideStartMark: false, // 控制是否隐藏0%标记
72
- disabled: false
73
- };
74
- },
75
- computed: {
76
- progress() {
77
- const value = this.value;
78
- if (typeof value === 'undefined' || value === null) return 0;
79
- const progressValue = Math.floor((value - this.min) / (this.max - this.min) * 100);
80
- return this.language === 'ar' ? 100 - progressValue : progressValue;
81
- },
82
- progressWidth() {
83
- const value = this.value;
84
- if (typeof value === 'undefined' || value === null) return 0;
85
- const progressValue = Math.floor((value - this.min) / (this.max - this.min) * 100);
86
- return progressValue;
87
- },
88
- inputStyle() {
89
- if (this.language === 'ar') {
90
- return {
91
- left: 'auto',
92
- right: this.progress + '%'
93
- };
94
- } else {
95
- return {
96
- left: this.progress + '%',
97
- right: 'auto'
98
- };
99
- }
100
- }
101
- },
102
- watch: {
103
-
104
- },
105
- mounted() {
106
-
107
-
108
- const thumb = this.$refs.thumb;
109
- const content = this.$refs.content;
110
- const getThumbPosition = () => {
111
- const contentBox = content.getBoundingClientRect();
112
- const thumbBox = thumb.getBoundingClientRect();
113
- return {
114
- left: thumbBox.left - contentBox.left,
115
- top: thumbBox.top - contentBox.top,
116
- thumbBoxLeft: thumbBox.left
117
- };
118
- };
119
-
120
- let dragState = {};
121
- draggable(thumb, {
122
- start: (event) => {
123
- if (this.disabled) return;
124
- this.showMarks = true;
125
- const position = getThumbPosition();
126
- const thumbClickDetalX = event.clientX - position.thumbBoxLeft;
127
- dragState = {
128
- thumbStartLeft: position.left,
129
- thumbStartTop: position.top,
130
- thumbClickDetalX: thumbClickDetalX
131
- };
132
- },
133
- drag: (event) => {
134
- if (this.disabled) return;
135
- const contentBox = content.getBoundingClientRect();
136
- const deltaX = this.language === 'ar' ?
137
- contentBox.right - event.pageX - dragState.thumbStartLeft - dragState.thumbClickDetalX :
138
- event.pageX - contentBox.left - dragState.thumbStartLeft - dragState.thumbClickDetalX;
139
- // const deltaX = event.pageX - contentBox.left - dragState.thumbStartLeft - dragState.thumbClickDetalX;
140
- const stepCount = Math.ceil((this.max - this.min) / this.step);
141
- const newPosition = (dragState.thumbStartLeft + deltaX) - (dragState.thumbStartLeft + deltaX) % (contentBox.width / stepCount);
142
-
143
- let newProgress = newPosition / contentBox.width;
144
-
145
- if (newProgress < 0) {
146
- newProgress = 0;
147
- } else if (newProgress > 1) {
148
- newProgress = 1;
149
- }
150
-
151
- this.$emit('input', Math.round(this.min + newProgress * (this.max - this.min)));
152
- },
153
- end: () => {
154
- if (this.disabled) return;
155
- this.$emit('change', this.value);
156
- dragState = {};
157
- }
158
- });
159
- }
160
- }
161
- </script>
162
-
163
- <style lang="less">
164
- @import './style.less';
165
-
166
-
167
- </style>