jsbox-cview 1.5.8 → 1.5.9
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.
|
@@ -11,6 +11,7 @@ export class ImagePager extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
11
11
|
_props: {
|
|
12
12
|
srcs: string[];
|
|
13
13
|
page: number;
|
|
14
|
+
doubleTapToZoom: boolean;
|
|
14
15
|
};
|
|
15
16
|
_matrix: Matrix;
|
|
16
17
|
_pageLoadRecorder: { [key: number]: boolean };
|
|
@@ -21,6 +22,7 @@ export class ImagePager extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
21
22
|
* @param props
|
|
22
23
|
* - srcs: string[] - 图片地址列表
|
|
23
24
|
* - page: number - 当前页码
|
|
25
|
+
* - doubleTapToZoom: boolean - 是否双击放大,默认为true
|
|
24
26
|
* @param layout
|
|
25
27
|
* @param events
|
|
26
28
|
* - changed: (page: number) => void - 页码变化时触发
|
|
@@ -30,6 +32,7 @@ export class ImagePager extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
30
32
|
props: {
|
|
31
33
|
srcs?: string[];
|
|
32
34
|
page?: number;
|
|
35
|
+
doubleTapToZoom?: boolean;
|
|
33
36
|
};
|
|
34
37
|
layout: (make: MASConstraintMaker, view: UIView) => void;
|
|
35
38
|
events: {
|
|
@@ -42,6 +45,7 @@ export class ImagePager extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
42
45
|
this._props = {
|
|
43
46
|
srcs: [],
|
|
44
47
|
page: 0,
|
|
48
|
+
doubleTapToZoom: true,
|
|
45
49
|
...props
|
|
46
50
|
};
|
|
47
51
|
this._pageLoadRecorder = {};
|
|
@@ -60,7 +64,7 @@ export class ImagePager extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
60
64
|
id: "scroll",
|
|
61
65
|
zoomEnabled: true,
|
|
62
66
|
maxZoomScale: 3,
|
|
63
|
-
doubleTapToZoom:
|
|
67
|
+
doubleTapToZoom: this._props.doubleTapToZoom
|
|
64
68
|
},
|
|
65
69
|
layout: $layout.fill,
|
|
66
70
|
views: [
|
|
@@ -84,6 +88,7 @@ export class ImagePager extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
84
88
|
ready: sender => {
|
|
85
89
|
// 如果没有此处的relayout,则会出现莫名其妙的bug
|
|
86
90
|
sender.relayout();
|
|
91
|
+
if (!this._matrix.view) return;
|
|
87
92
|
this.page = this.page;
|
|
88
93
|
this.loadsrc(this.page);
|
|
89
94
|
},
|
|
@@ -112,8 +117,7 @@ export class ImagePager extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
112
117
|
return {
|
|
113
118
|
type: "view",
|
|
114
119
|
props: {
|
|
115
|
-
id: this.id
|
|
116
|
-
userInteractionEnabled: true
|
|
120
|
+
id: this.id
|
|
117
121
|
},
|
|
118
122
|
layout,
|
|
119
123
|
views: [this._matrix.definition],
|
|
@@ -121,21 +125,11 @@ export class ImagePager extends Base<UIView, UiTypes.ViewOptions> {
|
|
|
121
125
|
layoutSubviews: sender => {
|
|
122
126
|
this._pageLoadRecorder = {};
|
|
123
127
|
sender.relayout();
|
|
128
|
+
if (!this._matrix.view) return;
|
|
124
129
|
this._matrix.view.reload();
|
|
125
130
|
this.page = this.page;
|
|
126
131
|
$delay(0.1, () => this.loadsrc(this.page, true));
|
|
127
132
|
$delay(0.3, () => this.loadsrc(this.page, true));
|
|
128
|
-
},
|
|
129
|
-
tapped: sender => {
|
|
130
|
-
const cell = this._matrix.view.cell($indexPath(0, this.page));
|
|
131
|
-
if (!cell) return;
|
|
132
|
-
const scroll = cell.get("scroll") as UIScrollView;
|
|
133
|
-
const zoomScale = scroll.zoomScale;
|
|
134
|
-
$delay(0.3, () => {
|
|
135
|
-
const zoomScale1 = scroll.zoomScale;
|
|
136
|
-
if (zoomScale === zoomScale1 && events.tapped)
|
|
137
|
-
events.tapped(this);
|
|
138
|
-
});
|
|
139
133
|
}
|
|
140
134
|
}
|
|
141
135
|
};
|
|
@@ -15,6 +15,7 @@ class ImagePager extends base_1.Base {
|
|
|
15
15
|
* @param props
|
|
16
16
|
* - srcs: string[] - 图片地址列表
|
|
17
17
|
* - page: number - 当前页码
|
|
18
|
+
* - doubleTapToZoom: boolean - 是否双击放大,默认为true
|
|
18
19
|
* @param layout
|
|
19
20
|
* @param events
|
|
20
21
|
* - changed: (page: number) => void - 页码变化时触发
|
|
@@ -22,7 +23,7 @@ class ImagePager extends base_1.Base {
|
|
|
22
23
|
*/
|
|
23
24
|
constructor({ props, layout, events = {} }) {
|
|
24
25
|
super();
|
|
25
|
-
this._props = Object.assign({ srcs: [], page: 0 }, props);
|
|
26
|
+
this._props = Object.assign({ srcs: [], page: 0, doubleTapToZoom: true }, props);
|
|
26
27
|
this._pageLoadRecorder = {};
|
|
27
28
|
this._matrix = new single_views_1.Matrix({
|
|
28
29
|
props: {
|
|
@@ -39,7 +40,7 @@ class ImagePager extends base_1.Base {
|
|
|
39
40
|
id: "scroll",
|
|
40
41
|
zoomEnabled: true,
|
|
41
42
|
maxZoomScale: 3,
|
|
42
|
-
doubleTapToZoom:
|
|
43
|
+
doubleTapToZoom: this._props.doubleTapToZoom
|
|
43
44
|
},
|
|
44
45
|
layout: $layout.fill,
|
|
45
46
|
views: [
|
|
@@ -63,6 +64,8 @@ class ImagePager extends base_1.Base {
|
|
|
63
64
|
ready: sender => {
|
|
64
65
|
// 如果没有此处的relayout,则会出现莫名其妙的bug
|
|
65
66
|
sender.relayout();
|
|
67
|
+
if (!this._matrix.view)
|
|
68
|
+
return;
|
|
66
69
|
this.page = this.page;
|
|
67
70
|
this.loadsrc(this.page);
|
|
68
71
|
},
|
|
@@ -91,8 +94,7 @@ class ImagePager extends base_1.Base {
|
|
|
91
94
|
return {
|
|
92
95
|
type: "view",
|
|
93
96
|
props: {
|
|
94
|
-
id: this.id
|
|
95
|
-
userInteractionEnabled: true
|
|
97
|
+
id: this.id
|
|
96
98
|
},
|
|
97
99
|
layout,
|
|
98
100
|
views: [this._matrix.definition],
|
|
@@ -100,22 +102,12 @@ class ImagePager extends base_1.Base {
|
|
|
100
102
|
layoutSubviews: sender => {
|
|
101
103
|
this._pageLoadRecorder = {};
|
|
102
104
|
sender.relayout();
|
|
105
|
+
if (!this._matrix.view)
|
|
106
|
+
return;
|
|
103
107
|
this._matrix.view.reload();
|
|
104
108
|
this.page = this.page;
|
|
105
109
|
$delay(0.1, () => this.loadsrc(this.page, true));
|
|
106
110
|
$delay(0.3, () => this.loadsrc(this.page, true));
|
|
107
|
-
},
|
|
108
|
-
tapped: sender => {
|
|
109
|
-
const cell = this._matrix.view.cell($indexPath(0, this.page));
|
|
110
|
-
if (!cell)
|
|
111
|
-
return;
|
|
112
|
-
const scroll = cell.get("scroll");
|
|
113
|
-
const zoomScale = scroll.zoomScale;
|
|
114
|
-
$delay(0.3, () => {
|
|
115
|
-
const zoomScale1 = scroll.zoomScale;
|
|
116
|
-
if (zoomScale === zoomScale1 && events.tapped)
|
|
117
|
-
events.tapped(this);
|
|
118
|
-
});
|
|
119
111
|
}
|
|
120
112
|
}
|
|
121
113
|
};
|