zartui 0.1.35 → 0.1.39

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 (47) hide show
  1. package/es/action-sheet/index.css +1 -1
  2. package/es/action-sheet/index.js +18 -13
  3. package/es/action-sheet/index.less +10 -1
  4. package/es/index.js +4 -3
  5. package/es/notice-bar/index.css +1 -0
  6. package/es/notice-bar/index.js +223 -0
  7. package/es/notice-bar/index.less +60 -0
  8. package/es/notice-bar/style/index.js +4 -0
  9. package/es/notice-bar/style/less.js +4 -0
  10. package/es/pdf-viewer/index.js +102 -49
  11. package/es/pdf-viewer/style/index.js +1 -0
  12. package/es/pdf-viewer/style/less.js +1 -0
  13. package/es/picker/index.js +11 -18
  14. package/es/picker/shared.js +8 -0
  15. package/es/popup/index.js +11 -0
  16. package/es/signature/force-landscape.js +97 -0
  17. package/es/signature/index.js +33 -13
  18. package/es/style/var.less +13 -10
  19. package/es/swipe/index.js +7 -1
  20. package/es/utils/create/component.js +4 -1
  21. package/es/utils/index.js +7 -0
  22. package/lib/action-sheet/index.css +1 -1
  23. package/lib/action-sheet/index.js +18 -13
  24. package/lib/action-sheet/index.less +10 -1
  25. package/lib/index.css +1 -1
  26. package/lib/index.js +6 -2
  27. package/lib/index.less +2 -1
  28. package/lib/notice-bar/index.css +1 -0
  29. package/lib/notice-bar/index.js +235 -0
  30. package/lib/notice-bar/index.less +60 -0
  31. package/lib/notice-bar/style/index.js +4 -0
  32. package/lib/notice-bar/style/less.js +4 -0
  33. package/lib/pdf-viewer/index.js +102 -51
  34. package/lib/pdf-viewer/style/index.js +1 -0
  35. package/lib/pdf-viewer/style/less.js +1 -0
  36. package/lib/picker/index.js +11 -18
  37. package/lib/picker/shared.js +8 -0
  38. package/lib/popup/index.js +11 -0
  39. package/lib/signature/force-landscape.js +110 -0
  40. package/lib/signature/index.js +34 -13
  41. package/lib/style/var.less +13 -10
  42. package/lib/swipe/index.js +7 -1
  43. package/lib/utils/create/component.js +7 -1
  44. package/lib/utils/index.js +9 -0
  45. package/lib/zart.js +598 -166
  46. package/lib/zart.min.js +4 -4
  47. package/package.json +1 -1
@@ -1 +1 @@
1
- .zt-action-sheet{display:-webkit-box;display:-webkit-flex;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;flex-direction:column;max-height:80%;overflow:hidden;color:rgba(0,0,0,.6)}.zt-action-sheet__content{-webkit-box-flex:1;-webkit-flex:1 auto;flex:1 auto;overflow-y:auto;-webkit-overflow-scrolling:touch}.zt-action-sheet__cancel,.zt-action-sheet__item{display:block;width:100%;padding:10px 16px;font-size:16px;line-height:24px;background-color:#fff;border:none;cursor:pointer}.zt-action-sheet__cancel:active,.zt-action-sheet__item:active{background-color:rgba(0,0,0,.04)}.zt-action-sheet__item{position:relative;color:#000}.zt-action-sheet__item:not(:last-child).zt-action-sheet__item::after{position:absolute;box-sizing:border-box;content:' ';pointer-events:none;right:0;bottom:0;left:0;border-bottom:1px solid rgba(0,0,0,.1);-webkit-transform:scaleY(.5);transform:scaleY(.5)}.zt-action-sheet__item--disabled,.zt-action-sheet__item--loading{color:rgba(0,0,0,.2)}.zt-action-sheet__item--disabled:active,.zt-action-sheet__item--loading:active{background-color:#fff}.zt-action-sheet__item--disabled{cursor:not-allowed}.zt-action-sheet__item--loading{cursor:default}.zt-action-sheet__cancel{-webkit-flex-shrink:0;flex-shrink:0;box-sizing:border-box;color:#000}.zt-action-sheet__subname{margin-top:8px;color:#969799;font-size:12px;line-height:18px}.zt-action-sheet__gap{display:block;height:12px;background-color:#f5f5fa}.zt-action-sheet__header{-webkit-flex-shrink:0;flex-shrink:0;font-size:14px;line-height:44px;text-align:center;position:relative;color:rgba(0,0,0,.4)}.zt-action-sheet__header::after{position:absolute;box-sizing:border-box;content:' ';pointer-events:none;right:0;bottom:0;left:0;border-bottom:1px solid rgba(0,0,0,.1);-webkit-transform:scaleY(.5);transform:scaleY(.5)}.zt-action-sheet__description{position:relative;-webkit-flex-shrink:0;flex-shrink:0;padding:20px 16px;color:#969799;font-size:14px;line-height:20px;text-align:center}.zt-action-sheet__description::after{position:absolute;box-sizing:border-box;content:' ';pointer-events:none;right:16px;bottom:0;left:16px;border-bottom:1px solid rgba(0,0,0,.1);-webkit-transform:scaleY(.5);transform:scaleY(.5)}.zt-action-sheet__loading-icon .zt-loading__spinner{width:22px;height:22px}.zt-action-sheet__close{position:absolute;top:0;right:0;padding:0 16px;color:#c8c9cc;font-size:22px;line-height:inherit}.zt-action-sheet__close:active{color:#969799}
1
+ .zt-action-sheet{display:-webkit-box;display:-webkit-flex;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;flex-direction:column;max-height:80%;overflow:hidden;color:rgba(0,0,0,.6)}.zt-action-sheet__content{-webkit-box-flex:1;-webkit-flex:1 auto;flex:1 auto;overflow-y:auto;-webkit-overflow-scrolling:touch}.zt-action-sheet__cancel,.zt-action-sheet__item{display:block;width:100%;padding:10px 16px;font-size:16px;line-height:24px;background-color:#fff;border:none;cursor:pointer}.zt-action-sheet__cancel:active,.zt-action-sheet__item:active{background-color:rgba(0,0,0,.04)}.zt-action-sheet__item{position:relative;color:#000}.zt-action-sheet__item:not(:last-child).zt-action-sheet__item::after{position:absolute;box-sizing:border-box;content:' ';pointer-events:none;right:0;bottom:0;left:0;border-bottom:1px solid rgba(0,0,0,.1);-webkit-transform:scaleY(.5);transform:scaleY(.5)}.zt-action-sheet__item--disabled,.zt-action-sheet__item--loading{color:rgba(0,0,0,.2)}.zt-action-sheet__item--disabled:active,.zt-action-sheet__item--loading:active{background-color:#fff}.zt-action-sheet__item--disabled{cursor:not-allowed}.zt-action-sheet__item--loading{cursor:default}.zt-action-sheet__item--has-subname{padding-top:9px;padding-bottom:9px}.zt-action-sheet__cancel{-webkit-flex-shrink:0;flex-shrink:0;box-sizing:border-box;color:#000}.zt-action-sheet__subname{margin-top:2px;color:#969799;font-size:12px;line-height:16px}.zt-action-sheet__gap{display:block;height:12px;background-color:#f5f5fa}.zt-action-sheet__header{-webkit-flex-shrink:0;flex-shrink:0;font-size:14px;line-height:44px;text-align:center;position:relative;color:rgba(0,0,0,.4)}.zt-action-sheet__header::after{position:absolute;box-sizing:border-box;content:' ';pointer-events:none;right:0;bottom:0;left:0;border-bottom:1px solid rgba(0,0,0,.1);-webkit-transform:scaleY(.5);transform:scaleY(.5)}.zt-action-sheet__header--align-start{text-align:start}.zt-action-sheet__description{position:relative;-webkit-flex-shrink:0;flex-shrink:0;padding:20px 16px;color:#969799;font-size:14px;line-height:20px;text-align:center}.zt-action-sheet__description::after{position:absolute;box-sizing:border-box;content:' ';pointer-events:none;right:16px;bottom:0;left:16px;border-bottom:1px solid rgba(0,0,0,.1);-webkit-transform:scaleY(.5);transform:scaleY(.5)}.zt-action-sheet__loading-icon .zt-loading__spinner{width:20px;height:20px}.zt-action-sheet__close{position:absolute;top:0;right:0;padding:0 16px;color:rgba(0,0,0,.4);font-size:20px;line-height:inherit}.zt-action-sheet__close:active{color:#969799}
@@ -26,6 +26,20 @@ function ActionSheet(h, props, slots, ctx) {
26
26
  }
27
27
 
28
28
  function Header() {
29
+ if (slots.title) {
30
+ return h("div", {
31
+ "class": bem('header', 'align-start')
32
+ }, [slots.title(), closeable && h(Icon, {
33
+ "attrs": {
34
+ "name": props.closeIcon
35
+ },
36
+ "class": bem('close'),
37
+ "on": {
38
+ "click": onCancel
39
+ }
40
+ })]);
41
+ }
42
+
29
43
  if (title) {
30
44
  return h("div", {
31
45
  "class": bem('header')
@@ -80,13 +94,15 @@ function ActionSheet(h, props, slots, ctx) {
80
94
  }, [item.subname])];
81
95
  }
82
96
 
97
+ var hasSubName = !loading && item.subname;
83
98
  return h("button", {
84
99
  "attrs": {
85
100
  "type": "button"
86
101
  },
87
102
  "class": [bem('item', {
88
103
  disabled: disabled,
89
- loading: loading
104
+ loading: loading,
105
+ 'has-subname': hasSubName
90
106
  }), item.className],
91
107
  "style": {
92
108
  color: item.color
@@ -113,16 +129,6 @@ function ActionSheet(h, props, slots, ctx) {
113
129
  }
114
130
  }
115
131
 
116
- function Description() {
117
- var description = (slots.description == null ? void 0 : slots.description()) || props.description;
118
-
119
- if (description) {
120
- return h("div", {
121
- "class": bem('description')
122
- }, [description]);
123
- }
124
- }
125
-
126
132
  return h(Popup, _mergeJSXProps([{
127
133
  "class": bem(),
128
134
  "attrs": {
@@ -138,7 +144,7 @@ function ActionSheet(h, props, slots, ctx) {
138
144
  "closeOnClickOverlay": props.closeOnClickOverlay,
139
145
  "safeAreaInsetBottom": props.safeAreaInsetBottom
140
146
  }
141
- }, inherit(ctx, true)]), [Header(), Description(), h("div", {
147
+ }, inherit(ctx, true)]), [Header(), h("div", {
142
148
  "class": bem('content')
143
149
  }, [props.actions && props.actions.map(Option), slots.default == null ? void 0 : slots.default()]), CancelText()]);
144
150
  }
@@ -148,7 +154,6 @@ ActionSheet.props = _extends({}, popupMixinProps, {
148
154
  actions: Array,
149
155
  duration: [Number, String],
150
156
  cancelText: String,
151
- description: String,
152
157
  getContainer: [String, Function],
153
158
  closeOnPopstate: Boolean,
154
159
  closeOnClickAction: Boolean,
@@ -54,6 +54,11 @@
54
54
  &--loading {
55
55
  cursor: default;
56
56
  }
57
+
58
+ &--has-subname {
59
+ padding-top: 9px;
60
+ padding-bottom: 9px;
61
+ }
57
62
  }
58
63
 
59
64
  &__cancel {
@@ -63,7 +68,7 @@
63
68
  }
64
69
 
65
70
  &__subname {
66
- margin-top: @padding-xs;
71
+ margin-top: 2px;
67
72
  color: @action-sheet-subname-color;
68
73
  font-size: @action-sheet-subname-font-size;
69
74
  line-height: @action-sheet-subname-line-height;
@@ -86,6 +91,10 @@
86
91
  &::after {
87
92
  .hairline-bottom(@cell-border-color);
88
93
  }
94
+
95
+ &--align-start {
96
+ text-align: start;
97
+ }
89
98
  }
90
99
 
91
100
  &__description {
package/es/index.js CHANGED
@@ -21,6 +21,7 @@ import Lazyload from './lazyload';
21
21
  import Loading from './loading';
22
22
  import Locale from './locale';
23
23
  import NavBar from './nav-bar';
24
+ import NoticeBar from './notice-bar';
24
25
  import NumberKeyboard from './number-keyboard';
25
26
  import Overlay from './overlay';
26
27
  import PasswordInput from './password-input';
@@ -47,10 +48,10 @@ import Tabs from './tabs';
47
48
  import Tag from './tag';
48
49
  import Toast from './toast';
49
50
  import Uploader from './uploader';
50
- var version = '0.1.35';
51
+ var version = '0.1.39';
51
52
 
52
53
  function install(Vue) {
53
- var components = [ActionSheet, Area, Avatar, Button, Calendar, Cell, CellGroup, Checkbox, CheckboxGroup, Col, DatetimePicker, Dialog, Empty, Field, Form, Icon, Image, ImagePreview, Info, Lazyload, Loading, Locale, NavBar, NumberKeyboard, Overlay, PasswordInput, PdfViewer, Picker, Popup, Radio, RadioGroup, Rate, Row, Signature, Slider, Step, Stepper, Steps, Sticky, Swipe, SwipeCell, SwipeItem, Switch, SwitchCell, Tab, Tabs, Tag, Toast, Uploader];
54
+ var components = [ActionSheet, Area, Avatar, Button, Calendar, Cell, CellGroup, Checkbox, CheckboxGroup, Col, DatetimePicker, Dialog, Empty, Field, Form, Icon, Image, ImagePreview, Info, Lazyload, Loading, Locale, NavBar, NoticeBar, NumberKeyboard, Overlay, PasswordInput, PdfViewer, Picker, Popup, Radio, RadioGroup, Rate, Row, Signature, Slider, Step, Stepper, Steps, Sticky, Swipe, SwipeCell, SwipeItem, Switch, SwitchCell, Tab, Tabs, Tag, Toast, Uploader];
54
55
  components.forEach(function (item) {
55
56
  if (item.install) {
56
57
  Vue.use(item);
@@ -64,7 +65,7 @@ if (typeof window !== 'undefined' && window.Vue) {
64
65
  install(window.Vue);
65
66
  }
66
67
 
67
- export { install, version, ActionSheet, Area, Avatar, Button, Calendar, Cell, CellGroup, Checkbox, CheckboxGroup, Col, DatetimePicker, Dialog, Empty, Field, Form, Icon, Image, ImagePreview, Info, Lazyload, Loading, Locale, NavBar, NumberKeyboard, Overlay, PasswordInput, PdfViewer, Picker, Popup, Radio, RadioGroup, Rate, Row, Signature, Slider, Step, Stepper, Steps, Sticky, Swipe, SwipeCell, SwipeItem, Switch, SwitchCell, Tab, Tabs, Tag, Toast, Uploader };
68
+ export { install, version, ActionSheet, Area, Avatar, Button, Calendar, Cell, CellGroup, Checkbox, CheckboxGroup, Col, DatetimePicker, Dialog, Empty, Field, Form, Icon, Image, ImagePreview, Info, Lazyload, Loading, Locale, NavBar, NoticeBar, NumberKeyboard, Overlay, PasswordInput, PdfViewer, Picker, Popup, Radio, RadioGroup, Rate, Row, Signature, Slider, Step, Stepper, Steps, Sticky, Swipe, SwipeCell, SwipeItem, Switch, SwitchCell, Tab, Tabs, Tag, Toast, Uploader };
68
69
  export default {
69
70
  install: install,
70
71
  version: version
@@ -0,0 +1 @@
1
+ .zt-notice-bar{position:relative;display:-webkit-box;display:-webkit-flex;display:flex;-webkit-box-align:center;-webkit-align-items:center;align-items:center;height:36px;padding:0 12px 0 16px;color:#fa8500;font-size:14px;line-height:20px;background-color:rgba(255,205,35,.2)}.zt-notice-bar__left-icon,.zt-notice-bar__right-icon{min-width:24px;font-size:20px}.zt-notice-bar__right-icon{text-align:right;cursor:pointer}.zt-notice-bar__wrap{position:relative;display:-webkit-box;display:-webkit-flex;display:flex;-webkit-box-flex:1;-webkit-flex:1;flex:1;-webkit-box-align:center;-webkit-align-items:center;align-items:center;height:100%;overflow:hidden}.zt-notice-bar__content{position:absolute;white-space:nowrap;-webkit-transition-timing-function:linear;transition-timing-function:linear}.zt-notice-bar__content.zt-ellipsis{max-width:100%}.zt-notice-bar--wrapable{height:auto;padding:8px 16px}.zt-notice-bar--wrapable .zt-notice-bar__wrap{height:auto}.zt-notice-bar--wrapable .zt-notice-bar__content{position:relative;white-space:normal;word-wrap:break-word}
@@ -0,0 +1,223 @@
1
+ import { createNamespace, isDef } from '../utils';
2
+ import { doubleRaf, raf } from '../utils/dom/raf';
3
+ import { BindEventMixin } from '../mixins/bind-event';
4
+ import Icon from '../icon';
5
+
6
+ var _createNamespace = createNamespace('notice-bar'),
7
+ createComponent = _createNamespace[0],
8
+ bem = _createNamespace[1];
9
+
10
+ export default createComponent({
11
+ mixins: [BindEventMixin(function (bind) {
12
+ // fix cache issues with forwards and back history in safari
13
+ // see: https://guwii.com/cache-issues-with-forwards-and-back-history-in-safari/
14
+ bind(window, 'pageshow', this.reset);
15
+ })],
16
+ inject: {
17
+ ztPopup: {
18
+ default: null
19
+ }
20
+ },
21
+ props: {
22
+ text: String,
23
+ mode: String,
24
+ color: String,
25
+ leftIcon: String,
26
+ wrapable: Boolean,
27
+ background: String,
28
+ scrollable: {
29
+ type: Boolean,
30
+ default: null
31
+ },
32
+ delay: {
33
+ type: [Number, String],
34
+ default: 1
35
+ },
36
+ speed: {
37
+ type: [Number, String],
38
+ default: 60
39
+ }
40
+ },
41
+ data: function data() {
42
+ return {
43
+ show: true,
44
+ offset: 0,
45
+ duration: 0,
46
+ wrapWidth: 0,
47
+ contentWidth: 0
48
+ };
49
+ },
50
+ watch: {
51
+ scrollable: 'reset',
52
+ text: {
53
+ handler: 'reset',
54
+ immediate: true
55
+ }
56
+ },
57
+ created: function created() {
58
+ // https://github.com/youzan/vant/issues/8634
59
+ if (this.ztPopup) {
60
+ this.ztPopup.onReopen(this.reset);
61
+ }
62
+ },
63
+ activated: function activated() {
64
+ this.reset();
65
+ },
66
+ methods: {
67
+ onClickIcon: function onClickIcon(event) {
68
+ if (this.mode === 'closeable') {
69
+ this.show = false;
70
+ this.$emit('close', event);
71
+ }
72
+ },
73
+ onTransitionEnd: function onTransitionEnd() {
74
+ var _this = this;
75
+
76
+ this.offset = this.wrapWidth;
77
+ this.duration = 0; // wait for Vue to render offset
78
+ // using nextTick won't work in iOS14
79
+
80
+ raf(function () {
81
+ // use double raf to ensure animation can start
82
+ doubleRaf(function () {
83
+ _this.offset = -_this.contentWidth;
84
+ _this.duration = (_this.contentWidth + _this.wrapWidth) / _this.speed;
85
+
86
+ _this.$emit('replay');
87
+ });
88
+ });
89
+ },
90
+ // not an exposed-api, but may used by some users
91
+ start: function start() {
92
+ this.reset();
93
+ },
94
+ // @exposed-api
95
+ reset: function reset() {
96
+ var _this2 = this;
97
+
98
+ var delay = isDef(this.delay) ? this.delay * 1000 : 0;
99
+ this.offset = 0;
100
+ this.duration = 0;
101
+ this.wrapWidth = 0;
102
+ this.contentWidth = 0;
103
+ clearTimeout(this.startTimer);
104
+ this.startTimer = setTimeout(function () {
105
+ var _this2$$refs = _this2.$refs,
106
+ wrap = _this2$$refs.wrap,
107
+ content = _this2$$refs.content;
108
+
109
+ if (!wrap || !content || _this2.scrollable === false) {
110
+ return;
111
+ }
112
+
113
+ var wrapWidth = wrap.getBoundingClientRect().width;
114
+ var contentWidth = content.getBoundingClientRect().width;
115
+
116
+ if (_this2.scrollable || contentWidth > wrapWidth) {
117
+ doubleRaf(function () {
118
+ _this2.offset = -contentWidth;
119
+ _this2.duration = contentWidth / _this2.speed;
120
+ _this2.wrapWidth = wrapWidth;
121
+ _this2.contentWidth = contentWidth;
122
+ });
123
+ }
124
+ }, delay);
125
+ }
126
+ },
127
+ render: function render() {
128
+ var _this3 = this;
129
+
130
+ var h = arguments[0];
131
+ var slots = this.slots,
132
+ mode = this.mode,
133
+ leftIcon = this.leftIcon,
134
+ onClickIcon = this.onClickIcon;
135
+ var barStyle = {
136
+ color: this.color,
137
+ background: this.background
138
+ };
139
+ var contentStyle = {
140
+ transform: this.offset ? "translateX(" + this.offset + "px)" : '',
141
+ transitionDuration: this.duration + 's'
142
+ };
143
+
144
+ function LeftIcon() {
145
+ var slot = slots('left-icon');
146
+
147
+ if (slot) {
148
+ return slot;
149
+ }
150
+
151
+ if (leftIcon) {
152
+ return h(Icon, {
153
+ "class": bem('left-icon'),
154
+ "attrs": {
155
+ "name": leftIcon
156
+ }
157
+ });
158
+ }
159
+ }
160
+
161
+ function RightIcon() {
162
+ var slot = slots('right-icon');
163
+
164
+ if (slot) {
165
+ return slot;
166
+ }
167
+
168
+ var iconName;
169
+
170
+ if (mode === 'closeable') {
171
+ iconName = 'close';
172
+ } else if (mode === 'link') {
173
+ iconName = 'arrow';
174
+ }
175
+
176
+ if (iconName) {
177
+ return h(Icon, {
178
+ "class": bem('right-icon'),
179
+ "attrs": {
180
+ "name": iconName
181
+ },
182
+ "on": {
183
+ "click": onClickIcon
184
+ }
185
+ });
186
+ }
187
+ }
188
+
189
+ return h("div", {
190
+ "attrs": {
191
+ "role": "alert"
192
+ },
193
+ "directives": [{
194
+ name: "show",
195
+ value: this.show
196
+ }],
197
+ "class": bem({
198
+ wrapable: this.wrapable
199
+ }),
200
+ "style": barStyle,
201
+ "on": {
202
+ "click": function click(event) {
203
+ _this3.$emit('click', event);
204
+ }
205
+ }
206
+ }, [LeftIcon(), h("div", {
207
+ "ref": "wrap",
208
+ "class": bem('wrap'),
209
+ "attrs": {
210
+ "role": "marquee"
211
+ }
212
+ }, [h("div", {
213
+ "ref": "content",
214
+ "class": [bem('content'), {
215
+ 'zt-ellipsis': this.scrollable === false && !this.wrapable
216
+ }],
217
+ "style": contentStyle,
218
+ "on": {
219
+ "transitionend": this.onTransitionEnd
220
+ }
221
+ }, [this.slots() || this.text])]), RightIcon()]);
222
+ }
223
+ });
@@ -0,0 +1,60 @@
1
+ @import '../style/var';
2
+
3
+ .zt-notice-bar {
4
+ position: relative;
5
+ display: flex;
6
+ align-items: center;
7
+ height: @notice-bar-height;
8
+ padding: @notice-bar-padding;
9
+ color: @notice-bar-text-color;
10
+ font-size: @notice-bar-font-size;
11
+ line-height: @notice-bar-line-height;
12
+ background-color: @notice-bar-background-color;
13
+
14
+ &__left-icon,
15
+ &__right-icon {
16
+ min-width: @notice-bar-icon-min-width;
17
+ font-size: @notice-bar-icon-size;
18
+ }
19
+
20
+ &__right-icon {
21
+ text-align: right;
22
+ cursor: pointer;
23
+ }
24
+
25
+ &__wrap {
26
+ position: relative;
27
+ display: flex;
28
+ flex: 1;
29
+ align-items: center;
30
+ height: 100%;
31
+ overflow: hidden;
32
+ }
33
+
34
+ &__content {
35
+ position: absolute;
36
+ white-space: nowrap;
37
+ transition-timing-function: linear;
38
+
39
+ &.zt-ellipsis {
40
+ max-width: 100%;
41
+ }
42
+ }
43
+
44
+ &--wrapable {
45
+ height: auto;
46
+ padding: @notice-bar-wrapable-padding;
47
+
48
+ .zt-notice-bar {
49
+ &__wrap {
50
+ height: auto;
51
+ }
52
+
53
+ &__content {
54
+ position: relative;
55
+ white-space: normal;
56
+ word-wrap: break-word;
57
+ }
58
+ }
59
+ }
60
+ }
@@ -0,0 +1,4 @@
1
+ import '../../style/base.css';
2
+ import '../../info/index.css';
3
+ import '../../icon/index.css';
4
+ import '../index.css';
@@ -0,0 +1,4 @@
1
+ import '../../style/base.less';
2
+ import '../../info/index.less';
3
+ import '../../icon/index.less';
4
+ import '../index.less';
@@ -9,10 +9,33 @@ import pdf from "egova-vue-pdf";
9
9
  Vue.use(pdf);
10
10
  import Toast from '../toast';
11
11
  import Loading from '../loading';
12
- import Popup from '../popup';
12
+ import Picker from '../picker';
13
13
 
14
14
  var _ = require('lodash');
15
15
 
16
+ import { resetObject } from "../utils/index";
17
+
18
+ var defaultData = function defaultData() {
19
+ return {
20
+ loadingTask: null,
21
+ pdfPageCount: 0,
22
+ pageNum: 1,
23
+ loadedRatio: 0,
24
+ loading: false,
25
+ rotateDegree: 0,
26
+ pdfArr: [],
27
+ pageChangeByButton: false,
28
+ showPicker: false,
29
+ bodyInitialHeight: "auto",
30
+ bodyInitialMinHeight: "auto",
31
+ metaContent: "",
32
+ steps: 1,
33
+ allStep: 0,
34
+ timer: null,
35
+ completeLoaded: false
36
+ };
37
+ };
38
+
16
39
  export default createComponent({
17
40
  props: {
18
41
  url: {
@@ -21,19 +44,7 @@ export default createComponent({
21
44
  }
22
45
  },
23
46
  data: function data() {
24
- return {
25
- pdfPageCount: 0,
26
- pageNum: 1,
27
- loadedRatio: 0,
28
- loading: false,
29
- rotateDegree: 0,
30
- pdfArr: [],
31
- pageChangeByButton: false,
32
- showPicker: false,
33
- bodyInitialHeight: "auto",
34
- bodyInitialMinHeight: "auto",
35
- metaContent: ""
36
- };
47
+ return defaultData();
37
48
  },
38
49
  mounted: function mounted() {
39
50
  var _document$getElements;
@@ -81,47 +92,87 @@ export default createComponent({
81
92
  document.body.style.minHeight = '100%';
82
93
  },
83
94
  reset: function reset() {
84
- this.pdfPageCount = 0;
85
- this.pageNum = 1;
95
+ this.clearTimer();
96
+ resetObject(this, defaultData());
86
97
  },
87
- getPdfNumPages: function getPdfNumPages() {
98
+ clearTimer: function clearTimer() {
99
+ if (this.timer) {
100
+ clearInterval(this.timer);
101
+ this.timer = null;
102
+ }
103
+ },
104
+ startPdfLoaderTimer: function startPdfLoaderTimer() {
88
105
  var _this = this;
89
106
 
107
+ // 一次加载10页,定时器分布加载后续内容
108
+ var stepPages = 10;
109
+ this.allStep = Math.floor(this.pdfPageCount / stepPages);
110
+
111
+ var loadPage = function loadPage() {
112
+ if (_this.pdfArr.length < _this.pdfPageCount) {
113
+ var max = _this.steps * stepPages < _this.pdfPageCount ? _this.steps * stepPages : _this.pdfPageCount;
114
+
115
+ for (var i = (_this.steps - 1) * stepPages; i < max; i++) {
116
+ _this.pdfArr.push({});
117
+ }
118
+
119
+ _this.steps++;
120
+ } else {
121
+ _this.clearTimer();
122
+
123
+ _this.completeLoaded = true;
124
+
125
+ _this.changePage();
126
+ }
127
+ };
128
+
129
+ loadPage();
130
+ this.timer = setInterval(function () {
131
+ loadPage();
132
+ }, 500);
133
+ },
134
+ getPdfNumPages: function getPdfNumPages() {
135
+ var _this2 = this;
136
+
90
137
  if (!this.url) {
91
138
  return;
92
139
  }
93
140
 
94
141
  this.loading = true;
95
- var loadingTask = pdf.createLoadingTask(this.url);
96
- loadingTask.promise.then(function (v) {
97
- _this.pdfPageCount = v.numPages;
98
- var pdfArr = [];
142
+ this.loadingTask = pdf.createLoadingTask(this.url);
143
+ this.loadingTask.promise.then(function (v) {
144
+ _this2.pdfPageCount = v.numPages;
99
145
 
100
- for (var i = 0; i < _this.pdfPageCount; i++) {
101
- pdfArr.push({});
102
- }
146
+ _this2.startPdfLoaderTimer();
103
147
 
104
- _this.pdfArr = pdfArr;
105
148
  window.onscroll = _.throttle(function () {
106
- if (_this.pageChangeByButton) {
107
- _this.pageChangeByButton = false;
149
+ if (_this2.pageChangeByButton) {
150
+ _this2.pageChangeByButton = false;
108
151
  } else {
109
- _this.changePage();
152
+ _this2.changePage();
110
153
  }
111
154
  }, 300);
112
155
  }).catch(function (err) {
113
156
  console.error("pdf 加载失败", err);
114
157
  }).finally(function () {
115
- _this.loading = false;
158
+ _this2.loading = false;
116
159
  });
117
160
  },
118
161
  changePage: function changePage() {
162
+ if (!this.completeLoaded) {
163
+ return;
164
+ }
165
+
166
+ if (window.pageYOffset === 0) {
167
+ this.pageNum = 1;
168
+ }
169
+
119
170
  var i = 1,
120
171
  count = this.pdfPageCount;
121
172
 
122
173
  do {
123
174
  if (window.pageYOffset >= this.findPos(document.getElementById("pdfContent" + i)) && window.pageYOffset <= this.findPos(document.getElementById("pdfContent" + (i + 1)))) {
124
- this.pageNum = i;
175
+ this.pageNum = i + 1;
125
176
  }
126
177
 
127
178
  i++;
@@ -169,11 +220,12 @@ export default createComponent({
169
220
  var h = this.$createElement;
170
221
  return h("div", [h(pdf, {
171
222
  "attrs": {
172
- "src": this.url,
223
+ "src": this.loadingTask,
173
224
  "page": i,
174
225
  "id": "pdfContent" + i,
175
226
  "rotate": this.rotateDegree
176
227
  },
228
+ "key": i,
177
229
  "ref": "pdfContent" + i,
178
230
  "on": {
179
231
  "loaded": this.onPdfLoaded,
@@ -186,25 +238,18 @@ export default createComponent({
186
238
  showPagePicker: function showPagePicker() {
187
239
  this.showPicker = true;
188
240
  },
189
- genPageList: function genPageList() {
190
- var _this2 = this;
191
-
192
- var h = this.$createElement;
241
+ getPageList: function getPageList() {
193
242
  return this.pdfArr.map(function (v, i) {
194
- return h("div", {
195
- "class": bem("page-item"),
196
- "on": {
197
- "click": function click() {
198
- return _this2.setPage(i + 1);
199
- }
200
- }
201
- }, [i + 1]);
243
+ return i + 1;
202
244
  });
203
245
  },
204
246
  setPage: function setPage(i) {
205
247
  this.pageNum = i;
206
248
  this.pageChangeByButton = true;
207
249
  this.showPicker = false;
250
+ },
251
+ cancel: function cancel() {
252
+ this.showPicker = false;
208
253
  }
209
254
  },
210
255
  render: function render(h) {
@@ -217,6 +262,10 @@ export default createComponent({
217
262
  }) : h(), h("div", {
218
263
  "class": bem("pdf-top")
219
264
  }, [h("div", {
265
+ "directives": [{
266
+ name: "show",
267
+ value: this.completeLoaded
268
+ }],
220
269
  "class": bem("page-btn")
221
270
  }, [h("svg", {
222
271
  "attrs": {
@@ -274,13 +323,17 @@ export default createComponent({
274
323
  }
275
324
  }, [this.pdfArr.map(function (x, i) {
276
325
  return _this3.genPdf(i + 1);
277
- })]) : h(), h(Popup, {
278
- "class": bem('popup'),
326
+ })]) : h(), h(Picker, {
279
327
  "attrs": {
280
- "value": this.showPicker,
281
- "position": "bottom",
282
- "closeOnClickOverlay": false
328
+ "show-picker": this.showPicker,
329
+ "default-index": this.pageNum - 1,
330
+ "title": "页码",
331
+ "columns": this.getPageList()
332
+ },
333
+ "on": {
334
+ "cancel": this.cancel,
335
+ "confirm": this.setPage
283
336
  }
284
- }, [this.genPageList()])]);
337
+ })]);
285
338
  }
286
339
  });
@@ -5,4 +5,5 @@ import '../../icon/index.css';
5
5
  import '../../popup/index.css';
6
6
  import '../../loading/index.css';
7
7
  import '../../toast/index.css';
8
+ import '../../picker/index.css';
8
9
  import '../index.css';