zartui 0.1.45 → 0.1.46
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/es/index.js +5 -3
- package/es/list/index.css +1 -0
- package/es/list/index.js +178 -0
- package/es/list/index.less +17 -0
- package/es/list/style/index.js +3 -0
- package/es/list/style/less.js +3 -0
- package/es/locale/index.js +5 -5
- package/es/pull-refresh/index.css +1 -0
- package/es/pull-refresh/index.js +214 -0
- package/es/pull-refresh/index.less +25 -0
- package/es/pull-refresh/style/index.js +3 -0
- package/es/pull-refresh/style/less.js +3 -0
- package/es/signature/index.js +10 -0
- package/es/sticky/index.css +1 -1
- package/es/sticky/index.js +23 -11
- package/es/sticky/index.less +3 -0
- package/lib/index.css +1 -1
- package/lib/index.js +10 -2
- package/lib/index.less +2 -0
- package/lib/list/index.css +1 -0
- package/lib/list/index.js +191 -0
- package/lib/list/index.less +17 -0
- package/lib/list/style/index.js +3 -0
- package/lib/list/style/less.js +3 -0
- package/lib/locale/index.js +5 -5
- package/lib/pull-refresh/index.css +1 -0
- package/lib/pull-refresh/index.js +228 -0
- package/lib/pull-refresh/index.less +25 -0
- package/lib/pull-refresh/style/index.js +3 -0
- package/lib/pull-refresh/style/less.js +3 -0
- package/lib/signature/index.js +10 -0
- package/lib/sticky/index.css +1 -1
- package/lib/sticky/index.js +23 -11
- package/lib/sticky/index.less +3 -0
- package/lib/zart.js +438 -18
- package/lib/zart.min.js +3 -3
- package/package.json +1 -1
package/es/index.js
CHANGED
|
@@ -25,6 +25,7 @@ import Image from './image';
|
|
|
25
25
|
import ImagePreview from './image-preview';
|
|
26
26
|
import Info from './info';
|
|
27
27
|
import Lazyload from './lazyload';
|
|
28
|
+
import List from './list';
|
|
28
29
|
import Loading from './loading';
|
|
29
30
|
import Locale from './locale';
|
|
30
31
|
import NavBar from './nav-bar';
|
|
@@ -35,6 +36,7 @@ import PasswordInput from './password-input';
|
|
|
35
36
|
import PdfViewer from './pdf-viewer';
|
|
36
37
|
import Picker from './picker';
|
|
37
38
|
import Popup from './popup';
|
|
39
|
+
import PullRefresh from './pull-refresh';
|
|
38
40
|
import Radio from './radio';
|
|
39
41
|
import RadioGroup from './radio-group';
|
|
40
42
|
import Rate from './rate';
|
|
@@ -59,10 +61,10 @@ import Tabs from './tabs';
|
|
|
59
61
|
import Tag from './tag';
|
|
60
62
|
import Toast from './toast';
|
|
61
63
|
import Uploader from './uploader';
|
|
62
|
-
var version = '0.1.
|
|
64
|
+
var version = '0.1.46';
|
|
63
65
|
|
|
64
66
|
function install(Vue) {
|
|
65
|
-
var components = [ActionSheet, Area, Avatar, Badge, Button, Calendar, Cell, CellGroup, Checkbox, CheckboxGroup, Col, Collapse, CollapseItem, CountDown, DatetimePicker, Dialog, Divider, DropdownItem, DropdownMenu, Empty, Field, Form, Icon, Image, ImagePreview, Info, Lazyload, Loading, Locale, NavBar, NoticeBar, NumberKeyboard, Overlay, PasswordInput, PdfViewer, Picker, Popup, Radio, RadioGroup, Rate, Row, Search, Signature, Skeleton, Slider, Step, Stepper, Steps, Sticky, Swipe, SwipeCell, SwipeItem, Switch, SwitchCell, Tab, Tabbar, TabbarItem, Tabs, Tag, Toast, Uploader];
|
|
67
|
+
var components = [ActionSheet, Area, Avatar, Badge, Button, Calendar, Cell, CellGroup, Checkbox, CheckboxGroup, Col, Collapse, CollapseItem, CountDown, DatetimePicker, Dialog, Divider, DropdownItem, DropdownMenu, Empty, Field, Form, Icon, Image, ImagePreview, Info, Lazyload, List, Loading, Locale, NavBar, NoticeBar, NumberKeyboard, Overlay, PasswordInput, PdfViewer, Picker, Popup, PullRefresh, Radio, RadioGroup, Rate, Row, Search, Signature, Skeleton, Slider, Step, Stepper, Steps, Sticky, Swipe, SwipeCell, SwipeItem, Switch, SwitchCell, Tab, Tabbar, TabbarItem, Tabs, Tag, Toast, Uploader];
|
|
66
68
|
components.forEach(function (item) {
|
|
67
69
|
if (item.install) {
|
|
68
70
|
Vue.use(item);
|
|
@@ -76,7 +78,7 @@ if (typeof window !== 'undefined' && window.Vue) {
|
|
|
76
78
|
install(window.Vue);
|
|
77
79
|
}
|
|
78
80
|
|
|
79
|
-
export { install, version, ActionSheet, Area, Avatar, Badge, Button, Calendar, Cell, CellGroup, Checkbox, CheckboxGroup, Col, Collapse, CollapseItem, CountDown, DatetimePicker, Dialog, Divider, DropdownItem, DropdownMenu, Empty, Field, Form, Icon, Image, ImagePreview, Info, Lazyload, Loading, Locale, NavBar, NoticeBar, NumberKeyboard, Overlay, PasswordInput, PdfViewer, Picker, Popup, Radio, RadioGroup, Rate, Row, Search, Signature, Skeleton, Slider, Step, Stepper, Steps, Sticky, Swipe, SwipeCell, SwipeItem, Switch, SwitchCell, Tab, Tabbar, TabbarItem, Tabs, Tag, Toast, Uploader };
|
|
81
|
+
export { install, version, ActionSheet, Area, Avatar, Badge, Button, Calendar, Cell, CellGroup, Checkbox, CheckboxGroup, Col, Collapse, CollapseItem, CountDown, DatetimePicker, Dialog, Divider, DropdownItem, DropdownMenu, Empty, Field, Form, Icon, Image, ImagePreview, Info, Lazyload, List, Loading, Locale, NavBar, NoticeBar, NumberKeyboard, Overlay, PasswordInput, PdfViewer, Picker, Popup, PullRefresh, Radio, RadioGroup, Rate, Row, Search, Signature, Skeleton, Slider, Step, Stepper, Steps, Sticky, Swipe, SwipeCell, SwipeItem, Switch, SwitchCell, Tab, Tabbar, TabbarItem, Tabs, Tag, Toast, Uploader };
|
|
80
82
|
export default {
|
|
81
83
|
install: install,
|
|
82
84
|
version: version
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.zt-list__error-text,.zt-list__finished-text,.zt-list__loading{color:#969799;font-size:14px;line-height:50px;text-align:center}.zt-list__placeholder{height:0;pointer-events:none}
|
package/es/list/index.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
// Utils
|
|
2
|
+
import { createNamespace } from '../utils';
|
|
3
|
+
import { isHidden } from '../utils/dom/style';
|
|
4
|
+
import { getScroller } from '../utils/dom/scroll'; // Mixins
|
|
5
|
+
|
|
6
|
+
import { BindEventMixin } from '../mixins/bind-event'; // Components
|
|
7
|
+
|
|
8
|
+
import Loading from '../loading';
|
|
9
|
+
|
|
10
|
+
var _createNamespace = createNamespace('list'),
|
|
11
|
+
createComponent = _createNamespace[0],
|
|
12
|
+
bem = _createNamespace[1],
|
|
13
|
+
t = _createNamespace[2];
|
|
14
|
+
|
|
15
|
+
export default createComponent({
|
|
16
|
+
mixins: [BindEventMixin(function (bind) {
|
|
17
|
+
if (!this.scroller) {
|
|
18
|
+
this.scroller = getScroller(this.$el);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
bind(this.scroller, 'scroll', this.check);
|
|
22
|
+
})],
|
|
23
|
+
model: {
|
|
24
|
+
prop: 'loading'
|
|
25
|
+
},
|
|
26
|
+
props: {
|
|
27
|
+
error: Boolean,
|
|
28
|
+
loading: Boolean,
|
|
29
|
+
finished: Boolean,
|
|
30
|
+
errorText: String,
|
|
31
|
+
loadingText: String,
|
|
32
|
+
finishedText: String,
|
|
33
|
+
immediateCheck: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: true
|
|
36
|
+
},
|
|
37
|
+
offset: {
|
|
38
|
+
type: [Number, String],
|
|
39
|
+
default: 300
|
|
40
|
+
},
|
|
41
|
+
direction: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: 'down'
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
data: function data() {
|
|
47
|
+
return {
|
|
48
|
+
// use sync innerLoading state to avoid repeated loading in some edge cases
|
|
49
|
+
innerLoading: this.loading
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
updated: function updated() {
|
|
53
|
+
this.innerLoading = this.loading;
|
|
54
|
+
},
|
|
55
|
+
mounted: function mounted() {
|
|
56
|
+
if (this.immediateCheck) {
|
|
57
|
+
this.check();
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
watch: {
|
|
61
|
+
loading: 'check',
|
|
62
|
+
finished: 'check'
|
|
63
|
+
},
|
|
64
|
+
methods: {
|
|
65
|
+
// @exposed-api
|
|
66
|
+
check: function check() {
|
|
67
|
+
var _this = this;
|
|
68
|
+
|
|
69
|
+
this.$nextTick(function () {
|
|
70
|
+
if (_this.innerLoading || _this.finished || _this.error) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
var el = _this.$el,
|
|
75
|
+
scroller = _this.scroller,
|
|
76
|
+
offset = _this.offset,
|
|
77
|
+
direction = _this.direction;
|
|
78
|
+
var scrollerRect;
|
|
79
|
+
|
|
80
|
+
if (scroller.getBoundingClientRect) {
|
|
81
|
+
scrollerRect = scroller.getBoundingClientRect();
|
|
82
|
+
} else {
|
|
83
|
+
scrollerRect = {
|
|
84
|
+
top: 0,
|
|
85
|
+
bottom: scroller.innerHeight
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
var scrollerHeight = scrollerRect.bottom - scrollerRect.top;
|
|
90
|
+
/* istanbul ignore next */
|
|
91
|
+
|
|
92
|
+
if (!scrollerHeight || isHidden(el)) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
var isReachEdge = false;
|
|
97
|
+
|
|
98
|
+
var placeholderRect = _this.$refs.placeholder.getBoundingClientRect();
|
|
99
|
+
|
|
100
|
+
if (direction === 'up') {
|
|
101
|
+
isReachEdge = scrollerRect.top - placeholderRect.top <= offset;
|
|
102
|
+
} else {
|
|
103
|
+
isReachEdge = placeholderRect.bottom - scrollerRect.bottom <= offset;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (isReachEdge) {
|
|
107
|
+
_this.innerLoading = true;
|
|
108
|
+
|
|
109
|
+
_this.$emit('input', true);
|
|
110
|
+
|
|
111
|
+
_this.$emit('load');
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
clickErrorText: function clickErrorText() {
|
|
116
|
+
this.$emit('update:error', false);
|
|
117
|
+
this.check();
|
|
118
|
+
},
|
|
119
|
+
genLoading: function genLoading() {
|
|
120
|
+
var h = this.$createElement;
|
|
121
|
+
|
|
122
|
+
if (this.innerLoading && !this.finished) {
|
|
123
|
+
return h("div", {
|
|
124
|
+
"key": "loading",
|
|
125
|
+
"class": bem('loading')
|
|
126
|
+
}, [this.slots('loading') || h(Loading, {
|
|
127
|
+
"attrs": {
|
|
128
|
+
"size": "16"
|
|
129
|
+
}
|
|
130
|
+
}, [this.loadingText || t('loading')])]);
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
genFinishedText: function genFinishedText() {
|
|
134
|
+
var h = this.$createElement;
|
|
135
|
+
|
|
136
|
+
if (this.finished) {
|
|
137
|
+
var text = this.slots('finished') || this.finishedText;
|
|
138
|
+
|
|
139
|
+
if (text) {
|
|
140
|
+
return h("div", {
|
|
141
|
+
"class": bem('finished-text')
|
|
142
|
+
}, [text]);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
genErrorText: function genErrorText() {
|
|
147
|
+
var h = this.$createElement;
|
|
148
|
+
|
|
149
|
+
if (this.error) {
|
|
150
|
+
var text = this.slots('error') || this.errorText;
|
|
151
|
+
|
|
152
|
+
if (text) {
|
|
153
|
+
return h("div", {
|
|
154
|
+
"on": {
|
|
155
|
+
"click": this.clickErrorText
|
|
156
|
+
},
|
|
157
|
+
"class": bem('error-text')
|
|
158
|
+
}, [text]);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
render: function render() {
|
|
164
|
+
var h = arguments[0];
|
|
165
|
+
var Placeholder = h("div", {
|
|
166
|
+
"ref": "placeholder",
|
|
167
|
+
"key": "placeholder",
|
|
168
|
+
"class": bem('placeholder')
|
|
169
|
+
});
|
|
170
|
+
return h("div", {
|
|
171
|
+
"class": bem(),
|
|
172
|
+
"attrs": {
|
|
173
|
+
"role": "feed",
|
|
174
|
+
"aria-busy": this.innerLoading
|
|
175
|
+
}
|
|
176
|
+
}, [this.direction === 'down' ? this.slots() : Placeholder, this.genLoading(), this.genFinishedText(), this.genErrorText(), this.direction === 'up' ? this.slots() : Placeholder]);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
@import '../style/var';
|
|
2
|
+
|
|
3
|
+
.zt-list {
|
|
4
|
+
&__loading,
|
|
5
|
+
&__finished-text,
|
|
6
|
+
&__error-text {
|
|
7
|
+
color: @list-text-color;
|
|
8
|
+
font-size: @list-text-font-size;
|
|
9
|
+
line-height: @list-text-line-height;
|
|
10
|
+
text-align: center;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&__placeholder {
|
|
14
|
+
height: 0;
|
|
15
|
+
pointer-events: none;
|
|
16
|
+
}
|
|
17
|
+
}
|
package/es/locale/index.js
CHANGED
|
@@ -3,18 +3,18 @@ import { deepAssign } from '../utils/deep-assign';
|
|
|
3
3
|
import defaultMessages from './lang/zh-CN';
|
|
4
4
|
var proto = Vue.prototype;
|
|
5
5
|
var defineReactive = Vue.util.defineReactive;
|
|
6
|
-
defineReactive(proto, '$
|
|
7
|
-
defineReactive(proto, '$
|
|
6
|
+
defineReactive(proto, '$zartLang', 'zh-CN');
|
|
7
|
+
defineReactive(proto, '$zartMessages', {
|
|
8
8
|
'zh-CN': defaultMessages
|
|
9
9
|
});
|
|
10
10
|
export default {
|
|
11
11
|
messages: function messages() {
|
|
12
|
-
return proto.$
|
|
12
|
+
return proto.$zartMessages[proto.$zartLang];
|
|
13
13
|
},
|
|
14
14
|
use: function use(lang, messages) {
|
|
15
15
|
var _this$add;
|
|
16
16
|
|
|
17
|
-
proto.$
|
|
17
|
+
proto.$zartLang = lang;
|
|
18
18
|
this.add((_this$add = {}, _this$add[lang] = messages, _this$add));
|
|
19
19
|
},
|
|
20
20
|
add: function add(messages) {
|
|
@@ -22,6 +22,6 @@ export default {
|
|
|
22
22
|
messages = {};
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
deepAssign(proto.$
|
|
25
|
+
deepAssign(proto.$zartMessages, messages);
|
|
26
26
|
}
|
|
27
27
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.zt-pull-refresh{overflow:hidden;-webkit-user-select:none;user-select:none}.zt-pull-refresh__track{position:relative;height:100%;-webkit-transition-property:-webkit-transform;transition-property:-webkit-transform;transition-property:transform;transition-property:transform,-webkit-transform}.zt-pull-refresh__head{position:absolute;left:0;width:100%;height:50px;overflow:hidden;color:#969799;font-size:14px;line-height:50px;text-align:center;-webkit-transform:translateY(-100%);transform:translateY(-100%)}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
// Utils
|
|
2
|
+
import { createNamespace } from '../utils';
|
|
3
|
+
import { preventDefault } from '../utils/dom/event';
|
|
4
|
+
import { getScrollTop, getScroller } from '../utils/dom/scroll'; // Mixins
|
|
5
|
+
|
|
6
|
+
import { TouchMixin } from '../mixins/touch'; // Components
|
|
7
|
+
|
|
8
|
+
import Loading from '../loading';
|
|
9
|
+
|
|
10
|
+
var _createNamespace = createNamespace('pull-refresh'),
|
|
11
|
+
createComponent = _createNamespace[0],
|
|
12
|
+
bem = _createNamespace[1],
|
|
13
|
+
t = _createNamespace[2];
|
|
14
|
+
|
|
15
|
+
var DEFAULT_HEAD_HEIGHT = 50;
|
|
16
|
+
var TEXT_STATUS = ['pulling', 'loosing', 'success'];
|
|
17
|
+
export default createComponent({
|
|
18
|
+
mixins: [TouchMixin],
|
|
19
|
+
props: {
|
|
20
|
+
disabled: Boolean,
|
|
21
|
+
successText: String,
|
|
22
|
+
pullingText: String,
|
|
23
|
+
loosingText: String,
|
|
24
|
+
loadingText: String,
|
|
25
|
+
pullDistance: [Number, String],
|
|
26
|
+
value: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
required: true
|
|
29
|
+
},
|
|
30
|
+
successDuration: {
|
|
31
|
+
type: [Number, String],
|
|
32
|
+
default: 500
|
|
33
|
+
},
|
|
34
|
+
animationDuration: {
|
|
35
|
+
type: [Number, String],
|
|
36
|
+
default: 300
|
|
37
|
+
},
|
|
38
|
+
headHeight: {
|
|
39
|
+
type: [Number, String],
|
|
40
|
+
default: DEFAULT_HEAD_HEIGHT
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
data: function data() {
|
|
44
|
+
return {
|
|
45
|
+
status: 'normal',
|
|
46
|
+
distance: 0,
|
|
47
|
+
duration: 0
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
computed: {
|
|
51
|
+
touchable: function touchable() {
|
|
52
|
+
return this.status !== 'loading' && this.status !== 'success' && !this.disabled;
|
|
53
|
+
},
|
|
54
|
+
headStyle: function headStyle() {
|
|
55
|
+
if (this.headHeight !== DEFAULT_HEAD_HEIGHT) {
|
|
56
|
+
return {
|
|
57
|
+
height: this.headHeight + "px"
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
watch: {
|
|
63
|
+
value: function value(loading) {
|
|
64
|
+
this.duration = this.animationDuration;
|
|
65
|
+
|
|
66
|
+
if (loading) {
|
|
67
|
+
this.setStatus(+this.headHeight, true);
|
|
68
|
+
} else if (this.slots('success') || this.successText) {
|
|
69
|
+
this.showSuccessTip();
|
|
70
|
+
} else {
|
|
71
|
+
this.setStatus(0, false);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
mounted: function mounted() {
|
|
76
|
+
this.bindTouchEvent(this.$refs.track);
|
|
77
|
+
this.scrollEl = getScroller(this.$el);
|
|
78
|
+
},
|
|
79
|
+
methods: {
|
|
80
|
+
checkPullStart: function checkPullStart(event) {
|
|
81
|
+
this.ceiling = getScrollTop(this.scrollEl) === 0;
|
|
82
|
+
|
|
83
|
+
if (this.ceiling) {
|
|
84
|
+
this.duration = 0;
|
|
85
|
+
this.touchStart(event);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
onTouchStart: function onTouchStart(event) {
|
|
89
|
+
if (this.touchable) {
|
|
90
|
+
this.checkPullStart(event);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
onTouchMove: function onTouchMove(event) {
|
|
94
|
+
if (!this.touchable) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (!this.ceiling) {
|
|
99
|
+
this.checkPullStart(event);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
this.touchMove(event);
|
|
103
|
+
|
|
104
|
+
if (this.ceiling && this.deltaY >= 0 && this.direction === 'vertical') {
|
|
105
|
+
preventDefault(event);
|
|
106
|
+
this.setStatus(this.ease(this.deltaY));
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
onTouchEnd: function onTouchEnd() {
|
|
110
|
+
var _this = this;
|
|
111
|
+
|
|
112
|
+
if (this.touchable && this.ceiling && this.deltaY) {
|
|
113
|
+
this.duration = this.animationDuration;
|
|
114
|
+
|
|
115
|
+
if (this.status === 'loosing') {
|
|
116
|
+
this.setStatus(+this.headHeight, true);
|
|
117
|
+
this.$emit('input', true); // ensure value change can be watched
|
|
118
|
+
|
|
119
|
+
this.$nextTick(function () {
|
|
120
|
+
_this.$emit('refresh');
|
|
121
|
+
});
|
|
122
|
+
} else {
|
|
123
|
+
this.setStatus(0);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
ease: function ease(distance) {
|
|
128
|
+
var pullDistance = +(this.pullDistance || this.headHeight);
|
|
129
|
+
|
|
130
|
+
if (distance > pullDistance) {
|
|
131
|
+
if (distance < pullDistance * 2) {
|
|
132
|
+
distance = pullDistance + (distance - pullDistance) / 2;
|
|
133
|
+
} else {
|
|
134
|
+
distance = pullDistance * 1.5 + (distance - pullDistance * 2) / 4;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return Math.round(distance);
|
|
139
|
+
},
|
|
140
|
+
setStatus: function setStatus(distance, isLoading) {
|
|
141
|
+
var status;
|
|
142
|
+
|
|
143
|
+
if (isLoading) {
|
|
144
|
+
status = 'loading';
|
|
145
|
+
} else if (distance === 0) {
|
|
146
|
+
status = 'normal';
|
|
147
|
+
} else {
|
|
148
|
+
status = distance < (this.pullDistance || this.headHeight) ? 'pulling' : 'loosing';
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
this.distance = distance;
|
|
152
|
+
|
|
153
|
+
if (status !== this.status) {
|
|
154
|
+
this.status = status;
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
genStatus: function genStatus() {
|
|
158
|
+
var h = this.$createElement;
|
|
159
|
+
var status = this.status,
|
|
160
|
+
distance = this.distance;
|
|
161
|
+
var slot = this.slots(status, {
|
|
162
|
+
distance: distance
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
if (slot) {
|
|
166
|
+
return slot;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
var nodes = [];
|
|
170
|
+
var text = this[status + "Text"] || t(status);
|
|
171
|
+
|
|
172
|
+
if (TEXT_STATUS.indexOf(status) !== -1) {
|
|
173
|
+
nodes.push(h("div", {
|
|
174
|
+
"class": bem('text')
|
|
175
|
+
}, [text]));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (status === 'loading') {
|
|
179
|
+
nodes.push(h(Loading, {
|
|
180
|
+
"attrs": {
|
|
181
|
+
"size": "16"
|
|
182
|
+
}
|
|
183
|
+
}, [text]));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return nodes;
|
|
187
|
+
},
|
|
188
|
+
showSuccessTip: function showSuccessTip() {
|
|
189
|
+
var _this2 = this;
|
|
190
|
+
|
|
191
|
+
this.status = 'success';
|
|
192
|
+
setTimeout(function () {
|
|
193
|
+
_this2.setStatus(0);
|
|
194
|
+
}, this.successDuration);
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
render: function render() {
|
|
198
|
+
var h = arguments[0];
|
|
199
|
+
var trackStyle = {
|
|
200
|
+
transitionDuration: this.duration + "ms",
|
|
201
|
+
transform: this.distance ? "translate3d(0," + this.distance + "px, 0)" : ''
|
|
202
|
+
};
|
|
203
|
+
return h("div", {
|
|
204
|
+
"class": bem()
|
|
205
|
+
}, [h("div", {
|
|
206
|
+
"ref": "track",
|
|
207
|
+
"class": bem('track'),
|
|
208
|
+
"style": trackStyle
|
|
209
|
+
}, [h("div", {
|
|
210
|
+
"class": bem('head'),
|
|
211
|
+
"style": this.headStyle
|
|
212
|
+
}, [this.genStatus()]), this.slots()])]);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
@import '../style/var';
|
|
2
|
+
|
|
3
|
+
.zt-pull-refresh {
|
|
4
|
+
overflow: hidden;
|
|
5
|
+
user-select: none;
|
|
6
|
+
|
|
7
|
+
&__track {
|
|
8
|
+
position: relative;
|
|
9
|
+
height: 100%;
|
|
10
|
+
transition-property: transform;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&__head {
|
|
14
|
+
position: absolute;
|
|
15
|
+
left: 0;
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: @pull-refresh-head-height;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
color: @pull-refresh-head-text-color;
|
|
20
|
+
font-size: @pull-refresh-head-font-size;
|
|
21
|
+
line-height: @pull-refresh-head-height;
|
|
22
|
+
text-align: center;
|
|
23
|
+
transform: translateY(-100%);
|
|
24
|
+
}
|
|
25
|
+
}
|
package/es/signature/index.js
CHANGED
|
@@ -200,6 +200,16 @@ export default createComponent({
|
|
|
200
200
|
|
|
201
201
|
_this3.ctx.fillRect(0, 0, _this3.$refs.canvas.width, _this3.$refs.canvas.height);
|
|
202
202
|
}, 50);
|
|
203
|
+
} else {
|
|
204
|
+
setTimeout(function () {
|
|
205
|
+
var backgroundColor = _this3.backgroundStyle;
|
|
206
|
+
|
|
207
|
+
if (backgroundColor !== 'transparent') {
|
|
208
|
+
_this3.ctx.fillStyle = backgroundColor;
|
|
209
|
+
|
|
210
|
+
_this3.ctx.fillRect(0, 0, _this3.$refs.canvas.width, _this3.$refs.canvas.height);
|
|
211
|
+
}
|
|
212
|
+
}, 50);
|
|
203
213
|
}
|
|
204
214
|
}
|
|
205
215
|
}
|
package/es/sticky/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.zt-sticky--fixed{position:fixed;top:0;right:0;left:0;z-index:99}
|
|
1
|
+
.zt-sticky--fixed{position:fixed;top:0;right:0;left:0;z-index:99}.zt-sticky__head{text-align:center}
|
package/es/sticky/index.js
CHANGED
|
@@ -61,6 +61,10 @@ export default createComponent({
|
|
|
61
61
|
pc: {
|
|
62
62
|
type: Boolean,
|
|
63
63
|
default: false
|
|
64
|
+
},
|
|
65
|
+
pulling: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
default: true
|
|
64
68
|
}
|
|
65
69
|
},
|
|
66
70
|
data: function data() {
|
|
@@ -75,7 +79,8 @@ export default createComponent({
|
|
|
75
79
|
touchOn: false,
|
|
76
80
|
refreshOffsetTop: null,
|
|
77
81
|
t1: 0,
|
|
78
|
-
t2: 0
|
|
82
|
+
t2: 0,
|
|
83
|
+
pull: false
|
|
79
84
|
};
|
|
80
85
|
},
|
|
81
86
|
computed: {
|
|
@@ -158,12 +163,16 @@ export default createComponent({
|
|
|
158
163
|
var emitScrollEvent = function emitScrollEvent() {
|
|
159
164
|
_this3.$emit('scroll', {
|
|
160
165
|
scrollTop: scrollTop,
|
|
161
|
-
isFixed: _this3.fixed
|
|
166
|
+
isFixed: _this3.fixed,
|
|
167
|
+
distance: overpx + scrollTop + offsetTopPx - topToPageTop
|
|
162
168
|
});
|
|
163
169
|
};
|
|
164
170
|
|
|
165
171
|
var overpx = this.refresh && this.lockfixed ? this.refreshDistance : 0; // The sticky component should be kept inside the container element
|
|
166
172
|
|
|
173
|
+
var currentY = document.documentElement.scrollTop || document.body.scrollTop;
|
|
174
|
+
this.pull = currentY < this.refreshtopToPageTop - this.offsetTopPx;
|
|
175
|
+
|
|
167
176
|
if (container) {
|
|
168
177
|
var bottomToPageTop = topToPageTop - overpx + container.offsetHeight;
|
|
169
178
|
|
|
@@ -219,7 +228,7 @@ export default createComponent({
|
|
|
219
228
|
_this.touchOn = false;
|
|
220
229
|
return;
|
|
221
230
|
} else if (_this.refresh && _this.fixed && currentY < _this.refreshtopToPageTop - _this.offsetTopPx) {
|
|
222
|
-
_this.$emit('
|
|
231
|
+
_this.$emit('refreshcallback');
|
|
223
232
|
|
|
224
233
|
_this.scrollAnimation(currentY, _this.refreshtopToPageTop - _this.refreshOffsetTop, true);
|
|
225
234
|
|
|
@@ -261,7 +270,7 @@ export default createComponent({
|
|
|
261
270
|
this.touchOn = false;
|
|
262
271
|
return;
|
|
263
272
|
} else if (this.refresh && this.deltaY > 0 && this.fixed && currentY < this.refreshtopToPageTop - this.offsetTopPx) {
|
|
264
|
-
this.$emit('
|
|
273
|
+
this.$emit('refreshcallback');
|
|
265
274
|
this.scrollAnimation(currentY, this.refreshtopToPageTop - this.refreshOffsetTop, true);
|
|
266
275
|
this.touchOn = false;
|
|
267
276
|
return;
|
|
@@ -272,12 +281,12 @@ export default createComponent({
|
|
|
272
281
|
renderLoading: function renderLoading() {
|
|
273
282
|
var h = this.$createElement;
|
|
274
283
|
|
|
275
|
-
if (this.lockfixed && this.refresh && this.touchOn &&
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
284
|
+
if (this.lockfixed && this.refresh && this.touchOn && this.pull && this.pulling) {
|
|
285
|
+
if (this.$slots.pull) {
|
|
286
|
+
return this.slots('pull');
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return h("zt-loading");
|
|
281
290
|
}
|
|
282
291
|
},
|
|
283
292
|
scrollAnimation: function scrollAnimation(currentY, targetY, lockfixed) {
|
|
@@ -321,6 +330,9 @@ export default createComponent({
|
|
|
321
330
|
fixed: fixed
|
|
322
331
|
}),
|
|
323
332
|
"style": this.style
|
|
324
|
-
}, [this.slots(),
|
|
333
|
+
}, [this.slots(), h("div", {
|
|
334
|
+
"class": bem('head'),
|
|
335
|
+
"style": this.headStyle
|
|
336
|
+
}, [this.renderLoading()])])]);
|
|
325
337
|
}
|
|
326
338
|
});
|