@shijiu/jsview-vue 0.9.426 → 0.9.502
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/dom/bin/jsview-browser-debug-dom.min.js +1 -1
- package/dom/bin/jsview-dom.min.js +1 -1
- package/dom/jsv-browser-debug-dom.js_1 +8 -0
- package/dom/jsv-dom.js_1 +6 -0
- package/dom/jsv-forge-define.js_1 +6 -0
- package/dom/target_core_revision.js +3 -3
- package/package.json +1 -1
- package/patches/node_modules/@vue/cli-service/lib/config/assets.js +1 -1
- package/patches/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js +4 -1
- package/samples/ColorSpace/App.vue +4 -4
- package/samples/DemoHomepage/router.js +17 -2
- package/samples/FilterDemo/App.vue +121 -0
- package/samples/GridDemo/App.vue +183 -0
- package/samples/GridDemo/ButtonBlock.vue +111 -0
- package/samples/GridDemo/FocusItem.vue +56 -0
- package/samples/GridDemo/Item.vue +101 -0
- package/samples/NinePatchDemo/App.vue +146 -0
- package/samples/NinePatchDemo/Item.vue +70 -0
- package/samples/NinePatchDemo/assets/border.png +0 -0
- package/samples/TouchSample/App.vue +137 -0
- package/samples/TouchSample/Item.vue +101 -0
- package/samples/TouchSample/MetroWidgetHorizontal.vue +144 -0
- package/samples/TouchSample/MetroWidgetVertical.vue +144 -0
- package/samples/TouchSample/TouchContainerHorizontal.vue +159 -0
- package/samples/TouchSample/TouchContainerVertical.vue +159 -0
- package/samples/TouchSample/data.js +81 -0
- package/samples/{ColorSpace → assets}/bmpDemo.bmp +0 -0
- package/samples/{ColorSpace → assets}/jpegDemo.jpeg +0 -0
- package/samples/{ColorSpace → assets}/pngDemo.png +0 -0
- package/samples/{ColorSpace → assets}/pngNoAlphaDemo.png +0 -0
- package/samples/assets/webpDemo.webp +0 -0
- package/scripts/jsview-jsmap-serve.js +63 -0
- package/scripts/jsview-post-build.js +50 -3
- package/scripts/jsview-post-install.js +22 -0
- package/utils/JsViewEngineWidget/JsvFocusBlock.vue +7 -5
- package/utils/JsViewEngineWidget/JsvFocusManager.js +5 -0
- package/utils/JsViewEngineWidget/MetroWidget/ItemView.vue +7 -14
- package/utils/JsViewEngineWidget/MetroWidget/MetroWidget.vue +214 -89
- package/utils/JsViewEngineWidget/MetroWidget/RootView.vue +4 -3
- package/utils/JsViewEngineWidget/SimpleWidget/SimpleWidget.vue +2 -0
- package/utils/JsViewEngineWidget/TemplateParser.js +8 -6
- package/utils/JsViewPlugin/JsvPlayer/GetVersion.js +20 -0
- package/utils/JsViewPlugin/JsvPlayer/JsvMedia.js +220 -85
- package/utils/JsViewPlugin/JsvPlayer/JsvPlayer.vue +43 -14
- package/utils/JsViewPlugin/JsvPlayer/JsvPlayerBrowser.vue +25 -12
- package/utils/JsViewPlugin/JsvPlayer/index.js +4 -0
- package/utils/JsViewPlugin/JsvPlayer/version.js +19 -0
- package/utils/JsViewVueTools/DebugTool.js +24 -0
- package/utils/JsViewVueTools/NinePatchHelper.js +44 -0
- package/utils/JsViewVueTools/TypeCheckAndSet.js +27 -0
- package/utils/JsViewVueWidget/BrowserDebugWidget/BrowserQrcode.vue +19 -8
- package/utils/JsViewVueWidget/BrowserDebugWidget/JsvApic/BrowserApic.vue +1 -1
- package/utils/JsViewVueWidget/JsvApic/JsvApic.vue +2 -2
- package/utils/JsViewVueWidget/JsvFilterView.vue +73 -0
- package/utils/JsViewVueWidget/JsvGrid.vue +573 -0
- package/utils/JsViewVueWidget/JsvInput/JsvInput.vue +7 -0
- package/utils/JsViewVueWidget/JsvNinePatch.vue +2 -2
- package/utils/JsViewVueWidget/JsvQrcode/JsvQrcode.vue +12 -3
- package/utils/JsViewVueWidget/JsvSpray/JsvSpray.vue +1 -1
- package/utils/JsViewVueWidget/JsvTextureAnim/CommonType.js +8 -0
- package/utils/JsViewVueWidget/JsvTextureAnim/JsvTextureAnim.vue +171 -38
- package/utils/JsViewVueWidget/JsvTextureAnim/index.js +3 -2
- package/utils/JsViewVueWidget/JsvTouchContainer.vue +184 -0
|
@@ -0,0 +1,573 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* 【界面概述】
|
|
3
|
+
* 表格式布局控件, 页面滚动时无动画. 一般用于对页面刷新速度有要求的场景
|
|
4
|
+
*
|
|
5
|
+
* 【控件介绍】
|
|
6
|
+
* JsvGrid:
|
|
7
|
+
* props:
|
|
8
|
+
* left {int} 控件的left
|
|
9
|
+
* top {int} 控件的top
|
|
10
|
+
* name {String} (必选)控件的焦点Id
|
|
11
|
+
* provideData {function} (必选)提供数据的接口, 数据中每个item均会包装成reactive对象,出于优化性能考虑, 请简化item中的属性
|
|
12
|
+
* row {int} (必选)布局的行数
|
|
13
|
+
* column {int} (必选)布局的列数
|
|
14
|
+
* itemSize {Object} 格子的大小 {width: 0, height: 0}
|
|
15
|
+
* updateType {UpdateType} 滚动的类型, 目前有两种PageType(整页), LineType(逐行)
|
|
16
|
+
* initFocusId {int} 初始的焦点
|
|
17
|
+
* gapInfo {Object} 格子间隔设置 {row: 行间距, colum: 列间距}
|
|
18
|
+
* verticalUpdate {boolean} 是否纵向滚动
|
|
19
|
+
* columnFirst {boolean} 单页是否列优先排布
|
|
20
|
+
* onEdge {function} 焦点移动到边缘时的回调
|
|
21
|
+
* @params {object} edgeInfo {
|
|
22
|
+
"direction": {EdgeDirection}边缘方向,
|
|
23
|
+
"rect": 到达边缘时的区域{x: 0, y: 0, width: 0,height: 0}
|
|
24
|
+
}
|
|
25
|
+
* methods:
|
|
26
|
+
getFocusBlockRef
|
|
27
|
+
@description 获取focusBlock的引用
|
|
28
|
+
@return {boolean} focusBlock的引用
|
|
29
|
+
setFocusId
|
|
30
|
+
@description 设置焦点id
|
|
31
|
+
@params {int} id 焦点id
|
|
32
|
+
refreshData
|
|
33
|
+
@description 刷新数据
|
|
34
|
+
* 【技巧说明】
|
|
35
|
+
* Q: 插槽props如何使用?
|
|
36
|
+
* A: userData: 通过provideData返回的数据会包装成reactive对象后给插槽内的item
|
|
37
|
+
* widgetData: 控件内部的关于item的属性
|
|
38
|
+
{
|
|
39
|
+
dataIndex: {int} 当前格子数据的index,
|
|
40
|
+
gridIndex: {int} 当前格子的index,
|
|
41
|
+
getCurrentFocusId: {function} 获取widget的当前焦点的dataIndex
|
|
42
|
+
}
|
|
43
|
+
* onAction: 单元格内控件需要通过onAction.register方法注册 item 的回调,回调函数有
|
|
44
|
+
onFocus, onBlur, onClick
|
|
45
|
+
*
|
|
46
|
+
* Q: 单元格的普通状态,焦点状态,失焦状态如何渲染?
|
|
47
|
+
* A: 在单元的空间中通过往onAction注册的onFocus,onBlur控制显示
|
|
48
|
+
*
|
|
49
|
+
* Q: 控件中的导航处理(上下左右,OK键)需要什么响应的开发?
|
|
50
|
+
* A: 上下左右键已经由控件接管,不需要开发者而外处理,上下左右键会触发翻页时间
|
|
51
|
+
*
|
|
52
|
+
* Q: 焦点怎么移出控件?
|
|
53
|
+
* A: 当焦点移动到控件边缘时,会调用onEdge回调。在回调中通过参数传递的值来决定焦点转移的行为
|
|
54
|
+
*
|
|
55
|
+
* Q: item内是可获焦的元素时该如何处理?
|
|
56
|
+
* A: 焦点处理: item内的元素需要在注册的onFocus中管理焦点. 子组件通过onKeyDown处理按键, 未处理的方向键会冒泡给JsvGrid, 从而触发格子间焦点的变换
|
|
57
|
+
-->
|
|
58
|
+
<script>
|
|
59
|
+
import { reactive } from "vue";
|
|
60
|
+
import { EdgeDirection } from "jsview/utils/JsViewEngineWidget";
|
|
61
|
+
|
|
62
|
+
const TAG = "JsvGrid";
|
|
63
|
+
|
|
64
|
+
const WHOLE_PAGE = 0;
|
|
65
|
+
const FIX_LINE = 1;
|
|
66
|
+
|
|
67
|
+
class UpdateType {
|
|
68
|
+
constructor(type) {
|
|
69
|
+
this.type = type;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
class PageType extends UpdateType {
|
|
74
|
+
constructor() {
|
|
75
|
+
super(WHOLE_PAGE);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
class LineType extends UpdateType {
|
|
80
|
+
constructor(start, end) {
|
|
81
|
+
super(FIX_LINE);
|
|
82
|
+
this.start = start;
|
|
83
|
+
this.end = end;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { PageType, LineType };
|
|
88
|
+
|
|
89
|
+
export default {
|
|
90
|
+
props: {
|
|
91
|
+
left: {
|
|
92
|
+
type: Number,
|
|
93
|
+
},
|
|
94
|
+
top: {
|
|
95
|
+
type: Number,
|
|
96
|
+
},
|
|
97
|
+
name: {
|
|
98
|
+
type: String,
|
|
99
|
+
},
|
|
100
|
+
provideData: {
|
|
101
|
+
type: Function,
|
|
102
|
+
require: true,
|
|
103
|
+
},
|
|
104
|
+
row: {
|
|
105
|
+
type: Number,
|
|
106
|
+
require: true,
|
|
107
|
+
},
|
|
108
|
+
column: {
|
|
109
|
+
type: Number,
|
|
110
|
+
require: true,
|
|
111
|
+
},
|
|
112
|
+
itemSize: {
|
|
113
|
+
type: Object,
|
|
114
|
+
require: true,
|
|
115
|
+
},
|
|
116
|
+
updateType: {
|
|
117
|
+
type: UpdateType,
|
|
118
|
+
default() {
|
|
119
|
+
return new PageType();
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
initFocusId: {
|
|
123
|
+
type: Number,
|
|
124
|
+
default: 0,
|
|
125
|
+
},
|
|
126
|
+
gapInfo: {
|
|
127
|
+
type: Object,
|
|
128
|
+
default() {
|
|
129
|
+
return {
|
|
130
|
+
row: 0,
|
|
131
|
+
column: 0,
|
|
132
|
+
};
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
verticalUpdate: {
|
|
136
|
+
type: Boolean,
|
|
137
|
+
},
|
|
138
|
+
columnFirst: {
|
|
139
|
+
type: Boolean,
|
|
140
|
+
},
|
|
141
|
+
onEdge: {
|
|
142
|
+
type: Function,
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
setup(props) {
|
|
146
|
+
return {
|
|
147
|
+
originDataList: [],
|
|
148
|
+
divInfoList: [],
|
|
149
|
+
startIndex: -1,
|
|
150
|
+
dataList: [],
|
|
151
|
+
dataInfo: {
|
|
152
|
+
endIndex: -1,
|
|
153
|
+
},
|
|
154
|
+
focusDataIndex: 0,
|
|
155
|
+
preFocusDataIndex: -1,
|
|
156
|
+
focused: false,
|
|
157
|
+
};
|
|
158
|
+
},
|
|
159
|
+
created() {
|
|
160
|
+
this._formatData();
|
|
161
|
+
this._initDivInfoList();
|
|
162
|
+
if (
|
|
163
|
+
this.initFocusId >= 0 &&
|
|
164
|
+
this.initFocusId < this.originDataList.length
|
|
165
|
+
) {
|
|
166
|
+
this.focusDataIndex = this._indexConvert(this.initFocusId);
|
|
167
|
+
}
|
|
168
|
+
this._updateData(this._getStartIndex(this.focusDataIndex, 1));
|
|
169
|
+
},
|
|
170
|
+
methods: {
|
|
171
|
+
_getCurrentFocusId() {
|
|
172
|
+
return this.dataList[this.focusDataIndex].originIndex;
|
|
173
|
+
},
|
|
174
|
+
_getDivIndex(dataIndex) {
|
|
175
|
+
return dataIndex - this.startIndex;
|
|
176
|
+
},
|
|
177
|
+
_initDivInfoList() {
|
|
178
|
+
this.divInfoList = new Array(this.row * this.column);
|
|
179
|
+
const realWidth = this.itemSize.width + this.gapInfo.column;
|
|
180
|
+
const realHeight = this.itemSize.height + this.gapInfo.row;
|
|
181
|
+
if (this.verticalUpdate) {
|
|
182
|
+
for (let i = 0; i < this.divInfoList.length; i++) {
|
|
183
|
+
this.divInfoList[i] = {
|
|
184
|
+
left: (i % this.column) * realWidth,
|
|
185
|
+
top: Math.floor(i / this.column) * realHeight,
|
|
186
|
+
onAction: {
|
|
187
|
+
register(name, func) {
|
|
188
|
+
this[name] = func;
|
|
189
|
+
},
|
|
190
|
+
unregister(name) {
|
|
191
|
+
delete this[name];
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
widgetData: reactive({
|
|
195
|
+
visibility: false,
|
|
196
|
+
dataIndex: -1,
|
|
197
|
+
gridIndex: i,
|
|
198
|
+
getCurrentFocusId: this._getCurrentFocusId,
|
|
199
|
+
}),
|
|
200
|
+
userData: reactive({}),
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
} else {
|
|
204
|
+
for (let i = 0; i < this.divInfoList.length; i++) {
|
|
205
|
+
this.divInfoList[i] = {
|
|
206
|
+
left: Math.floor(i / this.row) * realWidth,
|
|
207
|
+
top: (i % this.row) * realHeight,
|
|
208
|
+
onAction: {
|
|
209
|
+
register(name, func) {
|
|
210
|
+
this[name] = func;
|
|
211
|
+
},
|
|
212
|
+
unregister(name) {
|
|
213
|
+
delete this[name];
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
widgetData: reactive({
|
|
217
|
+
visibility: false,
|
|
218
|
+
dataIndex: -1,
|
|
219
|
+
gridIndex: i,
|
|
220
|
+
getCurrentFocusId: this._getCurrentFocusId,
|
|
221
|
+
}),
|
|
222
|
+
userData: reactive({}),
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
_cleanOldData() {
|
|
228
|
+
for (let i = 0; i < this.divInfoList.length; i++) {
|
|
229
|
+
this.divInfoList[i].widgetData.visibility = false;
|
|
230
|
+
this.divInfoList[i].widgetData.dataIndex = false;
|
|
231
|
+
|
|
232
|
+
for (let key in this.divInfoList[i].userData) {
|
|
233
|
+
this.divInfoList[i].userData[key] = null;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
_indexConvert(i) {
|
|
238
|
+
const pageItemNumber = this.row * this.column;
|
|
239
|
+
const pageStart = i - (i % pageItemNumber);
|
|
240
|
+
const pageIndex = i % pageItemNumber;
|
|
241
|
+
if (this.verticalUpdate && this.columnFirst) {
|
|
242
|
+
const r = pageIndex % this.row;
|
|
243
|
+
const c = Math.floor(pageIndex / this.row);
|
|
244
|
+
return c + r * this.column + pageStart;
|
|
245
|
+
} else if (!this.verticalUpdate && !this.columnFirst) {
|
|
246
|
+
const r = Math.floor(pageIndex / this.column);
|
|
247
|
+
const c = pageIndex % this.column;
|
|
248
|
+
return c * this.row + r + pageStart;
|
|
249
|
+
} else {
|
|
250
|
+
return i;
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
_formatData() {
|
|
254
|
+
this.originDataList = this.provideData();
|
|
255
|
+
const totalPage = Math.ceil(
|
|
256
|
+
this.originDataList.length / this.row / this.column
|
|
257
|
+
);
|
|
258
|
+
this.dataList = new Array(totalPage * this.row * this.column).fill(null);
|
|
259
|
+
let endIndex = -1;
|
|
260
|
+
for (let i = 0; i < this.originDataList.length; i++) {
|
|
261
|
+
const newIndex = this._indexConvert(i);
|
|
262
|
+
this.dataList[newIndex] = {
|
|
263
|
+
data: this.originDataList[i],
|
|
264
|
+
originIndex: i,
|
|
265
|
+
};
|
|
266
|
+
if (newIndex > endIndex) {
|
|
267
|
+
endIndex = newIndex;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
this.dataInfo.endIndex = endIndex;
|
|
271
|
+
},
|
|
272
|
+
_updateData(startIndex) {
|
|
273
|
+
if (this.startIndex === startIndex) return;
|
|
274
|
+
if (startIndex + this.row * this.column >= this.dataList.length) {
|
|
275
|
+
this.startIndex = this.dataList.length - this.row * this.column;
|
|
276
|
+
} else {
|
|
277
|
+
this.startIndex = startIndex;
|
|
278
|
+
}
|
|
279
|
+
for (let i = 0; i < this.divInfoList.length; i++) {
|
|
280
|
+
const item = this.divInfoList[i];
|
|
281
|
+
const data = this.dataList[i + this.startIndex];
|
|
282
|
+
if (data == null) {
|
|
283
|
+
item.widgetData.visibility = false;
|
|
284
|
+
} else {
|
|
285
|
+
item.widgetData.dataIndex = data.originIndex;
|
|
286
|
+
for (let key in data.data) {
|
|
287
|
+
item.userData[key] = data.data[key];
|
|
288
|
+
}
|
|
289
|
+
if (!item.widgetData.visibility) {
|
|
290
|
+
item.widgetData.visibility = true;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
_getStartIndex(targetIndex, direction) {
|
|
296
|
+
const type = this.updateType.type;
|
|
297
|
+
let preStartIndex = this.startIndex < 0 ? 0 : this.startIndex;
|
|
298
|
+
let startIndex = preStartIndex;
|
|
299
|
+
if (type == WHOLE_PAGE) {
|
|
300
|
+
startIndex = targetIndex - (targetIndex % (this.row * this.column));
|
|
301
|
+
} else if (type == FIX_LINE) {
|
|
302
|
+
const lineNum = this.verticalUpdate ? this.column : this.row;
|
|
303
|
+
const lastStartIndex = Math.max(
|
|
304
|
+
0,
|
|
305
|
+
this.dataInfo.endIndex +
|
|
306
|
+
lineNum -
|
|
307
|
+
(this.dataInfo.endIndex % lineNum) -
|
|
308
|
+
this.row * this.column
|
|
309
|
+
);
|
|
310
|
+
const targetLineStart = targetIndex - (targetIndex % lineNum);
|
|
311
|
+
// console.log(
|
|
312
|
+
// "_getStartIndex",
|
|
313
|
+
// `target:${targetIndex} targetStart:${targetLineStart} last:${lastStartIndex} preStart:${preStartIndex} direction:${direction}`
|
|
314
|
+
// );
|
|
315
|
+
if (targetLineStart >= preStartIndex + this.updateType.end * lineNum) {
|
|
316
|
+
startIndex = targetLineStart - this.updateType.end * lineNum;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if (
|
|
320
|
+
targetLineStart <=
|
|
321
|
+
preStartIndex + this.updateType.start * lineNum
|
|
322
|
+
) {
|
|
323
|
+
startIndex = targetLineStart - this.updateType.start * lineNum;
|
|
324
|
+
}
|
|
325
|
+
startIndex = Math.min(Math.max(0, startIndex), lastStartIndex);
|
|
326
|
+
}
|
|
327
|
+
return startIndex;
|
|
328
|
+
},
|
|
329
|
+
_sendOnEdge(edgeDirection, divIndex) {
|
|
330
|
+
let rect;
|
|
331
|
+
if (divIndex >= 0) {
|
|
332
|
+
let focusDiv = this.divInfoList[divIndex];
|
|
333
|
+
rect = {
|
|
334
|
+
x: focusDiv.left,
|
|
335
|
+
y: focusDiv.top,
|
|
336
|
+
width: this.itemSize.width,
|
|
337
|
+
height: this.itemSize.height,
|
|
338
|
+
};
|
|
339
|
+
} else {
|
|
340
|
+
rect = {
|
|
341
|
+
x: 0,
|
|
342
|
+
y: 0,
|
|
343
|
+
width: 0,
|
|
344
|
+
height: 0,
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
this.onEdge({ direction: edgeDirection, rect: rect });
|
|
349
|
+
},
|
|
350
|
+
_moveTo(hOffset, vOffset) {
|
|
351
|
+
let nextIndex = -1;
|
|
352
|
+
if (this.verticalUpdate) {
|
|
353
|
+
if (hOffset != 0) {
|
|
354
|
+
if (
|
|
355
|
+
!(this.focusDataIndex % this.column == 0 && hOffset < 0) &&
|
|
356
|
+
!(
|
|
357
|
+
this.focusDataIndex % this.column == this.column - 1 &&
|
|
358
|
+
hOffset > 0
|
|
359
|
+
) &&
|
|
360
|
+
this.dataList[this.focusDataIndex + hOffset]
|
|
361
|
+
) {
|
|
362
|
+
nextIndex = this.focusDataIndex + hOffset;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
if (vOffset != 0) {
|
|
366
|
+
nextIndex = this.focusDataIndex + vOffset * this.column;
|
|
367
|
+
if (nextIndex > 0 && !this.dataList[nextIndex]) {
|
|
368
|
+
if (nextIndex <= this.dataInfo.endIndex) {
|
|
369
|
+
nextIndex--;
|
|
370
|
+
while (!this.dataList[nextIndex]) {
|
|
371
|
+
nextIndex--;
|
|
372
|
+
}
|
|
373
|
+
} else {
|
|
374
|
+
nextIndex = -1;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
} else {
|
|
379
|
+
if (vOffset != 0) {
|
|
380
|
+
if (
|
|
381
|
+
!(this.focusDataIndex % this.row == 0 && vOffset < 0) &&
|
|
382
|
+
!(this.focusDataIndex % this.row == this.row - 1 && vOffset > 0) &&
|
|
383
|
+
this.dataList[this.focusDataIndex + vOffset]
|
|
384
|
+
) {
|
|
385
|
+
nextIndex = this.focusDataIndex + vOffset;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
if (hOffset != 0) {
|
|
389
|
+
nextIndex = this.focusDataIndex + hOffset * this.row;
|
|
390
|
+
if (nextIndex >= 0 && !this.dataList[nextIndex]) {
|
|
391
|
+
if (nextIndex <= this.dataInfo.endIndex) {
|
|
392
|
+
nextIndex--;
|
|
393
|
+
while (!this.dataList[nextIndex]) {
|
|
394
|
+
nextIndex--;
|
|
395
|
+
}
|
|
396
|
+
} else {
|
|
397
|
+
nextIndex = -1;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
if (nextIndex >= 0) {
|
|
403
|
+
let offset;
|
|
404
|
+
if (hOffset !== 0) {
|
|
405
|
+
offset = hOffset;
|
|
406
|
+
}
|
|
407
|
+
if (vOffset != 0) {
|
|
408
|
+
offset = vOffset;
|
|
409
|
+
}
|
|
410
|
+
this.preFocusDataIndex = this.focusDataIndex;
|
|
411
|
+
this.focusDataIndex = nextIndex;
|
|
412
|
+
if (this.preFocusDataIndex >= 0) {
|
|
413
|
+
this.divInfoList[
|
|
414
|
+
this._getDivIndex(this.preFocusDataIndex)
|
|
415
|
+
]?.onAction.onBlur?.();
|
|
416
|
+
}
|
|
417
|
+
this._updateData(this._getStartIndex(nextIndex, offset));
|
|
418
|
+
this.divInfoList[
|
|
419
|
+
this._getDivIndex(this.focusDataIndex)
|
|
420
|
+
]?.onAction.onFocus?.();
|
|
421
|
+
} else {
|
|
422
|
+
let edgeDirection;
|
|
423
|
+
if (hOffset > 0) {
|
|
424
|
+
edgeDirection = EdgeDirection.right;
|
|
425
|
+
}
|
|
426
|
+
if (hOffset < 0) {
|
|
427
|
+
edgeDirection = EdgeDirection.left;
|
|
428
|
+
}
|
|
429
|
+
if (vOffset > 0) {
|
|
430
|
+
edgeDirection = EdgeDirection.bottom;
|
|
431
|
+
}
|
|
432
|
+
if (vOffset < 0) {
|
|
433
|
+
edgeDirection = EdgeDirection.top;
|
|
434
|
+
}
|
|
435
|
+
this._sendOnEdge(edgeDirection, this._getDivIndex(this.focusDataIndex));
|
|
436
|
+
}
|
|
437
|
+
},
|
|
438
|
+
_onFocus() {
|
|
439
|
+
this.focused = true;
|
|
440
|
+
if (this.originDataList && this.originDataList.length > 0) {
|
|
441
|
+
this.divInfoList[
|
|
442
|
+
this._getDivIndex(this.focusDataIndex)
|
|
443
|
+
]?.onAction.onFocus?.();
|
|
444
|
+
} else {
|
|
445
|
+
console.warn(`${TAG}: ${this.name} focus while data is empty`);
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
_onBlur() {
|
|
449
|
+
this.focused = false;
|
|
450
|
+
if (this.originDataList && this.originDataList.length > 0) {
|
|
451
|
+
this.divInfoList[
|
|
452
|
+
this._getDivIndex(this.focusDataIndex)
|
|
453
|
+
]?.onAction.onBlur?.();
|
|
454
|
+
}
|
|
455
|
+
},
|
|
456
|
+
_onKeyDown(ev) {
|
|
457
|
+
if (!this.originDataList || this.originDataList.length == 0) {
|
|
458
|
+
const edgeDirectionMap = {
|
|
459
|
+
37: EdgeDirection.left,
|
|
460
|
+
38: EdgeDirection.top,
|
|
461
|
+
39: EdgeDirection.right,
|
|
462
|
+
40: EdgeDirection.bottom,
|
|
463
|
+
};
|
|
464
|
+
if (typeof edgeDirectionMap[ev.keyCode] !== "undefined") {
|
|
465
|
+
this._sendOnEdge(edgeDirectionMap[ev.keyCode], -1);
|
|
466
|
+
return true;
|
|
467
|
+
}
|
|
468
|
+
return false;
|
|
469
|
+
}
|
|
470
|
+
switch (ev.keyCode) {
|
|
471
|
+
case 37:
|
|
472
|
+
this._moveTo(-1, 0);
|
|
473
|
+
return true;
|
|
474
|
+
case 39:
|
|
475
|
+
this._moveTo(1, 0);
|
|
476
|
+
return true;
|
|
477
|
+
case 38:
|
|
478
|
+
this._moveTo(0, -1);
|
|
479
|
+
return true;
|
|
480
|
+
case 40:
|
|
481
|
+
this._moveTo(0, 1);
|
|
482
|
+
return true;
|
|
483
|
+
case 13:
|
|
484
|
+
this.divInfoList[
|
|
485
|
+
this._getDivIndex(this.focusDataIndex)
|
|
486
|
+
]?.onAction.onClick?.();
|
|
487
|
+
return true;
|
|
488
|
+
default:
|
|
489
|
+
return false;
|
|
490
|
+
}
|
|
491
|
+
},
|
|
492
|
+
|
|
493
|
+
getFocusBlockRef() {
|
|
494
|
+
return this.$refs.focusBlock;
|
|
495
|
+
},
|
|
496
|
+
|
|
497
|
+
setFocusId(id) {
|
|
498
|
+
if (id >= 0 && id < this.originDataList.length) {
|
|
499
|
+
let preIndex = this.focusDataIndex;
|
|
500
|
+
this.preFocusDataIndex = -1;
|
|
501
|
+
this.focusDataIndex = this._indexConvert(id);
|
|
502
|
+
if (this.focused) {
|
|
503
|
+
//焦点跳跃时之前的焦点可能不在divInfoList中
|
|
504
|
+
this.divInfoList[this._getDivIndex(preIndex)]?.onAction.onBlur?.();
|
|
505
|
+
}
|
|
506
|
+
this._updateData(this._getStartIndex(this.focusDataIndex, 1));
|
|
507
|
+
if (this.focused) {
|
|
508
|
+
this.divInfoList[
|
|
509
|
+
this._getDivIndex(this.focusDataIndex)
|
|
510
|
+
]?.onAction.onFocus?.();
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
},
|
|
514
|
+
|
|
515
|
+
refreshData() {
|
|
516
|
+
if (this.focused) {
|
|
517
|
+
//焦点跳跃时之前的焦点可能不在divInfoList中
|
|
518
|
+
this.divInfoList[
|
|
519
|
+
this._getDivIndex(this.focusDataIndex)
|
|
520
|
+
]?.onAction.onBlur?.();
|
|
521
|
+
}
|
|
522
|
+
this._formatData();
|
|
523
|
+
this.startIndex = -1;
|
|
524
|
+
this._cleanOldData();
|
|
525
|
+
if (this.focusDataIndex > this.originDataList.length) {
|
|
526
|
+
this.focusDataIndex = 0;
|
|
527
|
+
this.preFocusDataIndex = -1;
|
|
528
|
+
}
|
|
529
|
+
this._updateData(this._getStartIndex(this.focusDataIndex, 1));
|
|
530
|
+
if (this.focused) {
|
|
531
|
+
this.divInfoList[
|
|
532
|
+
this._getDivIndex(this.focusDataIndex)
|
|
533
|
+
]?.onAction.onFocus?.();
|
|
534
|
+
}
|
|
535
|
+
},
|
|
536
|
+
},
|
|
537
|
+
};
|
|
538
|
+
</script>
|
|
539
|
+
|
|
540
|
+
<template>
|
|
541
|
+
<jsv-focus-block
|
|
542
|
+
ref="focusBlock"
|
|
543
|
+
:name="name"
|
|
544
|
+
:onAction="{
|
|
545
|
+
onFocus: _onFocus,
|
|
546
|
+
onBlur: _onBlur,
|
|
547
|
+
onKeyDown: _onKeyDown,
|
|
548
|
+
}"
|
|
549
|
+
:style="{
|
|
550
|
+
left: left,
|
|
551
|
+
top: top,
|
|
552
|
+
}"
|
|
553
|
+
>
|
|
554
|
+
<div
|
|
555
|
+
v-for="(item, index) in divInfoList"
|
|
556
|
+
:key="index"
|
|
557
|
+
:style="{
|
|
558
|
+
left: item.left,
|
|
559
|
+
top: item.top,
|
|
560
|
+
width: itemSize.width,
|
|
561
|
+
height: itemSize.height,
|
|
562
|
+
visibility: item.widgetData.visibility ? 'inherit' : 'hidden',
|
|
563
|
+
}"
|
|
564
|
+
>
|
|
565
|
+
<slot
|
|
566
|
+
name="renderItem"
|
|
567
|
+
:userData="item.userData"
|
|
568
|
+
:widgetData="item.widgetData"
|
|
569
|
+
:onAction="item.onAction"
|
|
570
|
+
></slot>
|
|
571
|
+
</div>
|
|
572
|
+
</jsv-focus-block>
|
|
573
|
+
</template>
|
|
@@ -733,6 +733,13 @@ export default {
|
|
|
733
733
|
},
|
|
734
734
|
mounted() {},
|
|
735
735
|
beforeUnmount() {
|
|
736
|
+
if (this.editControlViewId != -1) {
|
|
737
|
+
const view_store = ForgeExtension.RootActivity
|
|
738
|
+
? ForgeExtension.RootActivity.ViewStore
|
|
739
|
+
: Forge.sViewStore;
|
|
740
|
+
view_store.remove(this.editControlViewId);
|
|
741
|
+
this.editControlViewId = -1;
|
|
742
|
+
}
|
|
736
743
|
this.clearCursorPauseTimer();
|
|
737
744
|
},
|
|
738
745
|
};
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
* 四角为90度圆弧时: imageDspWidth = 显示图形的圆弧半径 / 原图中圆弧的半径 * 原图宽度
|
|
12
12
|
* 原图中圆弧半径 = (原图宽度 - borderOutset * 2) / 2
|
|
13
13
|
* 四角为其他形状时,原图.9图的四角区域,缩放到要和显示图形重合后的宽度。
|
|
14
|
-
* borderOutset {int} (必填)原图信息:
|
|
14
|
+
* borderOutset {int} (必填)原图信息: 图片边缘到中心内容区域边缘的距离, 快速计算: (原图宽度 - 原图中放内容宽度) / 2
|
|
15
15
|
* animTime {int} (必填)缩放动画的时长(单位毫秒)
|
|
16
|
-
* waitForInit {boolean} 尺寸为0时是否进行描画(例如: 首次显示不展示动画的场合,设置为true),默认值为true
|
|
16
|
+
* waitForInit {boolean} (选填)尺寸为0时是否进行描画(例如: 首次显示不展示动画的场合,设置为true),默认值为true
|
|
17
17
|
-->
|
|
18
18
|
|
|
19
19
|
<script>
|
|
@@ -22,9 +22,18 @@ export default {
|
|
|
22
22
|
props: {
|
|
23
23
|
value: String,
|
|
24
24
|
size: Number,
|
|
25
|
-
fgColor:
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
fgColor: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: "#000000"
|
|
28
|
+
},
|
|
29
|
+
bgColor: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: "#ffffff"
|
|
32
|
+
},
|
|
33
|
+
level: {
|
|
34
|
+
type: String, // ,容错级别,分别是L(7%)、M(15%)、Q(25%)、H(30%),
|
|
35
|
+
default: "L"
|
|
36
|
+
},
|
|
28
37
|
imageSettings: Object,
|
|
29
38
|
},
|
|
30
39
|
methods: {
|