@shijiu/jsview-vue 0.9.631 → 0.9.684
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/bin/jsview-engine-js-browser.min.js +1 -0
- package/dom/target_core_revision.js +4 -4
- package/package.json +1 -1
- package/samples/Basic/components/text/TextOverflow.vue +8 -3
- package/samples/DemoHomepage/router.js +5 -0
- package/samples/Marquee/App.vue +176 -40
- package/samples/Marquee/longText.js +14 -0
- package/samples/MetroWidgetDemos/Advanced/App.vue +5 -6
- package/samples/MetroWidgetDemos/Advanced/ButtonItem.vue +1 -1
- package/samples/MetroWidgetDemos/Advanced/Buttons.vue +5 -5
- package/samples/MetroWidgetDemos/Advanced/Mixed.vue +4 -4
- package/samples/MetroWidgetDemos/Advanced/widgets/Item.vue +83 -0
- package/samples/MetroWidgetDemos/Advanced/widgets/WidgetItem.vue +89 -0
- package/samples/MetroWidgetDemos/Advanced/{Widgets.vue → widgets/Widgets.vue} +56 -11
- package/samples/MetroWidgetDemos/Advanced/widgets/focus1.png +0 -0
- package/samples/MetroWidgetDemos/Item.vue +20 -2
- package/samples/MetroWidgetDemos/Simple/AbsoluteTemplate.vue +2 -2
- package/samples/MetroWidgetDemos/Simple/App.vue +2 -2
- package/samples/MetroWidgetDemos/Simple/RelativeTemplate.vue +4 -4
- package/samples/MetroWidgetDemos/data.js +2 -1
- package/samples/ScaleDownNeon/App.vue +107 -0
- package/samples/TextBox/App.vue +7 -81
- package/samples/TextBox/RenderCenter.vue +40 -16
- package/samples/TextBox/RenderLeft.vue +48 -19
- package/samples/TextBox/RenderOneLine.vue +30 -49
- package/samples/TextBox/RenderRight.vue +40 -16
- package/samples/TextShadowDemo/App.vue +11 -17
- package/samples/TextureSize/App.vue +3 -3
- package/utils/JsViewEngineWidget/MetroWidget/Const.js +11 -0
- package/utils/JsViewEngineWidget/MetroWidget/MetroWidget.vue +188 -80
- package/utils/JsViewEngineWidget/TemplateParser.js +89 -32
- package/utils/JsViewEngineWidget/WidgetCommon.js +3 -4
- package/utils/JsViewEngineWidget/index.js +3 -2
- package/utils/JsViewPlugin/JsvPlayer/JsvMedia.js +61 -12
- package/utils/JsViewPlugin/JsvPlayer/JsvPlayer.vue +8 -1
- package/utils/JsViewPlugin/JsvPlayer/index.js +14 -0
- package/utils/JsViewPlugin/JsvPlayer/version.js +4 -4
- package/utils/JsViewVueWidget/JsvMarquee.vue +178 -205
- package/utils/JsViewVueWidget/JsvNativeSharedDiv.vue +35 -27
- package/utils/JsViewVueWidget/JsvNinePatch.vue +1 -2
- package/utils/JsViewVueWidget/JsvSwiper/JsvSwiper.vue +18 -2
- package/utils/JsViewVueWidget/JsvSwiper3D/JsvSwiper.vue +22 -2
- package/utils/JsViewVueWidget/JsvTextBox.vue +35 -72
- package/utils/JsViewVueWidget/JsvTouchContainer.vue +3 -4
- package/utils/JsViewVueWidget/utils/index.js +8 -0
- package/utils/JsViewVueWidget/utils/text.js +19 -0
- package/utils/JsViewEngineWidget/MetroPage.js +0 -2128
- package/utils/JsViewEngineWidget/SimpleWidget/ContentView.vue +0 -51
- package/utils/JsViewEngineWidget/SimpleWidget/Dispatcher.js +0 -19
- package/utils/JsViewEngineWidget/SimpleWidget/DivWrapper.vue +0 -53
- package/utils/JsViewEngineWidget/SimpleWidget/ItemView.vue +0 -142
- package/utils/JsViewEngineWidget/SimpleWidget/RootView.vue +0 -140
- package/utils/JsViewEngineWidget/SimpleWidget/SimpleWidget.vue +0 -1629
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Author: ChenChanghua
|
|
3
3
|
* @Date: 2021-09-22 16:08:58
|
|
4
4
|
* @LastEditors: ChenChanghua
|
|
5
|
-
* @LastEditTime: 2022-
|
|
5
|
+
* @LastEditTime: 2022-11-07 15:51:14
|
|
6
6
|
* @Description: file content
|
|
7
7
|
-->
|
|
8
8
|
|
|
@@ -52,15 +52,16 @@
|
|
|
52
52
|
* @params item {object} data中的数据
|
|
53
53
|
* @return 模板信息,
|
|
54
54
|
{
|
|
55
|
-
left: 绝对布局时的left,
|
|
56
|
-
top: 绝对布局时的top,
|
|
57
|
-
width: item的宽,
|
|
58
|
-
height: item的高,
|
|
59
|
-
focusable: item是否可以获得焦点,
|
|
60
|
-
marginBottom: item的下方margin,
|
|
61
|
-
marginRight: item的右方margin,
|
|
62
|
-
findNextAnchor: 自定义上下左右四条边寻找临近item的基准位置,值为0-1 {left: 0.5, right: 0.5, top: 0.5, bottom: 0.5}
|
|
63
|
-
doSlide: item获得焦点时是否滚动, 一般用于嵌套的情景,
|
|
55
|
+
left {int}: 绝对布局时的left,
|
|
56
|
+
top {int}: 绝对布局时的top,
|
|
57
|
+
width {int}: item的宽,
|
|
58
|
+
height {int}: item的高,
|
|
59
|
+
focusable {boolean}: item是否可以获得焦点,
|
|
60
|
+
marginBottom {int}: item的下方margin,
|
|
61
|
+
marginRight {int}: item的右方margin,
|
|
62
|
+
findNextAnchor {object}: 自定义上下左右四条边寻找临近item的基准位置,值为0-1 {left: 0.5, right: 0.5, top: 0.5, bottom: 0.5}
|
|
63
|
+
doSlide {boolean}: item获得焦点时是否滚动, 一般用于嵌套的情景, 由内部组件控制滚动,
|
|
64
|
+
zIndex {int | object}: item的zIndex, 为object时可以分别设置{focus: 0, normal: 0}, 为number时则同时设置获焦和不获焦的zIndex
|
|
64
65
|
}
|
|
65
66
|
*
|
|
66
67
|
* onFocus {function} 控件获取焦点的回调
|
|
@@ -110,9 +111,25 @@
|
|
|
110
111
|
@params {int} id 焦点id
|
|
111
112
|
@params {boolean} needSlide 是否需要滚动
|
|
112
113
|
@params {boolean} doAnim 滚动时是否做动画
|
|
114
|
+
@params {object} extraSetting 额外的参数设置
|
|
115
|
+
{
|
|
116
|
+
lockChildSlideEvent: {boolean} 设置焦点时忽略子发过来的滚动事件
|
|
117
|
+
}
|
|
113
118
|
refreshData
|
|
114
119
|
@description 刷新数据, 只有存在provideData时才会生效
|
|
115
120
|
@params {boolean} forceUpdate 是否强制刷新
|
|
121
|
+
getVisibleItems
|
|
122
|
+
@description 获取可视item的列表信息
|
|
123
|
+
@return {start: 开始的index, end: 结束的index, dataList: 可视item的数据列表}
|
|
124
|
+
lock
|
|
125
|
+
@description 设置内部的锁
|
|
126
|
+
@params {int} type 锁的类型, 通过|来实现多个类型的复合
|
|
127
|
+
SLIDE: 滚动动画锁
|
|
128
|
+
CHILD_SLIDE_EVENT: 子组件发送的滚动事件锁
|
|
129
|
+
@return {function} 解锁的函数
|
|
130
|
+
unlock
|
|
131
|
+
@description 解锁
|
|
132
|
+
@params {int} type 参考lock的type参数
|
|
116
133
|
* 【技巧说明】
|
|
117
134
|
* Q: 插槽props如何使用?
|
|
118
135
|
* A: data: 当前item的数据
|
|
@@ -123,8 +140,6 @@
|
|
|
123
140
|
获取 item 相对 MetroWidget 左上角坐标
|
|
124
141
|
templatePosition: {Function} (index : int) => {left: 0, top: 0, width: 0, height: 0}
|
|
125
142
|
获取 item 的布局坐标, 一般用于自定义滚动
|
|
126
|
-
absolutePosition: {Function} (index : int) => {left: 0, top: 0, width: 0, height: 0}
|
|
127
|
-
获取 item 的绝对坐标, 一般用于控制焦点
|
|
128
143
|
getCurrentFocusId: {Function} () => {id: 0, index: 0}
|
|
129
144
|
获取当前焦点信息,id 为在可获得焦点元素列表中的索引,index 为在所有元素列表中的索引
|
|
130
145
|
slideTo: {Function} (targetPosition : int, doAnim : Boolean) => void
|
|
@@ -175,6 +190,7 @@ import { TemplateParser, TemplateItemAdder } from "../TemplateParser";
|
|
|
175
190
|
import { PageUpdater } from "./PageUpdater";
|
|
176
191
|
import { SingleRangeModel } from "../RangeModel";
|
|
177
192
|
import Dispatcher from "./Dispatcher";
|
|
193
|
+
import { METRO_WIDGET } from "./Const";
|
|
178
194
|
import {
|
|
179
195
|
EdgeDirection,
|
|
180
196
|
VERTICAL,
|
|
@@ -409,6 +425,10 @@ let preUpdateVisibleStart = 0;
|
|
|
409
425
|
let mounted = false;
|
|
410
426
|
let focusNode = ref(null);
|
|
411
427
|
let pageRange = vertical ? props.height : props.width;
|
|
428
|
+
|
|
429
|
+
let slideLock = false;
|
|
430
|
+
let childSlideEventLock = false;
|
|
431
|
+
|
|
412
432
|
let visibleInfo = {
|
|
413
433
|
_start: 0,
|
|
414
434
|
range: 0,
|
|
@@ -489,10 +509,6 @@ const _getTemplatePosition = (index) => {
|
|
|
489
509
|
};
|
|
490
510
|
};
|
|
491
511
|
|
|
492
|
-
const _getAbsolutePosition = (index, targetEle) => {
|
|
493
|
-
return getPositionRelativeToView(innerData[index].itemDivRef, targetEle);
|
|
494
|
-
};
|
|
495
|
-
|
|
496
512
|
const _dispatchEvent = (event) => {
|
|
497
513
|
switch (event.type) {
|
|
498
514
|
case Dispatcher.Type.setEnterFocusId:
|
|
@@ -539,13 +555,22 @@ const onItemFocus = (index, rect) => {
|
|
|
539
555
|
}
|
|
540
556
|
};
|
|
541
557
|
|
|
542
|
-
const setFocusId = (id, needSlide = true, doAnim = false) => {
|
|
558
|
+
const setFocusId = (id, needSlide = true, doAnim = false, extraSetting) => {
|
|
559
|
+
if (id == focusId) {
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
543
562
|
templateItemAdder.tryAddItemById(id);
|
|
544
563
|
let next_focus_item = templateParser.GetItemById(id);
|
|
545
564
|
if (next_focus_item) {
|
|
546
565
|
if (needSlide) {
|
|
547
566
|
slideToItem(templateParser.FocusIdToIndex(id), doAnim);
|
|
548
567
|
}
|
|
568
|
+
let unlock = null;
|
|
569
|
+
if (extraSetting) {
|
|
570
|
+
if (extraSetting.lockChildSlideEvent) {
|
|
571
|
+
unlock = lock(METRO_WIDGET.CHILD_SLIDE_EVENT);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
549
574
|
|
|
550
575
|
const cur_focus_item = templateParser.GetItemById(focusId);
|
|
551
576
|
preFocusId = focusId;
|
|
@@ -566,6 +591,37 @@ const setFocusId = (id, needSlide = true, doAnim = false) => {
|
|
|
566
591
|
_updateFocusItem();
|
|
567
592
|
onItemBlur(templateParser.FocusIdToIndex(preFocusId));
|
|
568
593
|
onItemFocus(templateParser.FocusIdToIndex(focusId), preEdgeRect);
|
|
594
|
+
unlock?.();
|
|
595
|
+
}
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
const lock = (type) => {
|
|
599
|
+
const unlocker = [];
|
|
600
|
+
if (type & METRO_WIDGET.SLIDE) {
|
|
601
|
+
slideLock = true;
|
|
602
|
+
unlocker.push(() => {
|
|
603
|
+
slideLock = false;
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
if (type & METRO_WIDGET.CHILD_SLIDE_EVENT) {
|
|
607
|
+
childSlideEventLock = true;
|
|
608
|
+
unlocker.push(() => {
|
|
609
|
+
childSlideEventLock = false;
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
return () => {
|
|
613
|
+
unlocker.map((item) => {
|
|
614
|
+
item();
|
|
615
|
+
});
|
|
616
|
+
};
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
const unlock = (type) => {
|
|
620
|
+
if (type & METRO_WIDGET.SLIDE) {
|
|
621
|
+
slideLock = true;
|
|
622
|
+
}
|
|
623
|
+
if (type & METRO_WIDGET.CHILD_SLIDE_EVENT) {
|
|
624
|
+
childSlideEventLock = true;
|
|
569
625
|
}
|
|
570
626
|
};
|
|
571
627
|
|
|
@@ -693,7 +749,8 @@ const refreshData = (force_update) => {
|
|
|
693
749
|
dataList,
|
|
694
750
|
props.measures,
|
|
695
751
|
pageRange,
|
|
696
|
-
_onTemplateAdd
|
|
752
|
+
_onTemplateAdd,
|
|
753
|
+
props.name
|
|
697
754
|
);
|
|
698
755
|
}
|
|
699
756
|
if (need_update_content) {
|
|
@@ -748,7 +805,24 @@ const refreshData = (force_update) => {
|
|
|
748
805
|
}
|
|
749
806
|
};
|
|
750
807
|
|
|
808
|
+
const getVisibleItems = () => {
|
|
809
|
+
const info = templateParser.GetVisibleItemList(
|
|
810
|
+
visibleInfo.startWithPadding,
|
|
811
|
+
visibleInfo.endWithPadding,
|
|
812
|
+
focusId,
|
|
813
|
+
false,
|
|
814
|
+
null
|
|
815
|
+
);
|
|
816
|
+
return {
|
|
817
|
+
start: info.visibleStart,
|
|
818
|
+
end: info.visibleEnd,
|
|
819
|
+
dataList: dataList.slice(info.visibleStart, info.visibleEnd + 1),
|
|
820
|
+
};
|
|
821
|
+
};
|
|
822
|
+
|
|
751
823
|
const exportObject = {
|
|
824
|
+
lock,
|
|
825
|
+
unlock,
|
|
752
826
|
slideTo,
|
|
753
827
|
setFocusId,
|
|
754
828
|
getFocusBlockRef,
|
|
@@ -757,7 +831,7 @@ const exportObject = {
|
|
|
757
831
|
slideToItem,
|
|
758
832
|
refreshData,
|
|
759
833
|
_dispatchEvent,
|
|
760
|
-
|
|
834
|
+
getVisibleItems,
|
|
761
835
|
};
|
|
762
836
|
|
|
763
837
|
const _calculateNearestItemByRect = (visible_range, enter_rect_info) => {
|
|
@@ -1001,7 +1075,7 @@ const _onTemplateAdd = (item) => {
|
|
|
1001
1075
|
data: item,
|
|
1002
1076
|
index: innerData.length,
|
|
1003
1077
|
controller: reactive({
|
|
1004
|
-
zIndex: 0,
|
|
1078
|
+
zIndex: item.normalZIndex >= 0 ? item.normalZIndex : 0,
|
|
1005
1079
|
}),
|
|
1006
1080
|
mounted: false,
|
|
1007
1081
|
itemDivRef: null,
|
|
@@ -1059,7 +1133,6 @@ const _onTemplateAdd = (item) => {
|
|
|
1059
1133
|
index: item.index,
|
|
1060
1134
|
position: _getPosition,
|
|
1061
1135
|
templatePosition: _getTemplatePosition,
|
|
1062
|
-
absolutePosition: _getAbsolutePosition,
|
|
1063
1136
|
getCurrentFocusId: _getCurrentId,
|
|
1064
1137
|
slideTo: slideTo,
|
|
1065
1138
|
},
|
|
@@ -1094,6 +1167,9 @@ const _itemOnFocusSideEffect = (item, edgeRect) => {
|
|
|
1094
1167
|
|
|
1095
1168
|
const _onCustomerEvent = (ev) => {
|
|
1096
1169
|
if (ev.type === "focusRect") {
|
|
1170
|
+
if (childSlideEventLock) {
|
|
1171
|
+
return true;
|
|
1172
|
+
}
|
|
1097
1173
|
if (ev.ownerNode == exportObject) {
|
|
1098
1174
|
return false;
|
|
1099
1175
|
}
|
|
@@ -1198,21 +1274,31 @@ const _moveToNext = (
|
|
|
1198
1274
|
onend: _onSlideEnd,
|
|
1199
1275
|
};
|
|
1200
1276
|
_slideTo(visibleInfo.start, animObj);
|
|
1277
|
+
pageUpdater.update(
|
|
1278
|
+
templateParser,
|
|
1279
|
+
visibleInfo.startWithPadding - props.keepTraceRange * pageRange,
|
|
1280
|
+
Math.min(
|
|
1281
|
+
visibleInfo.startMax +
|
|
1282
|
+
visibleInfo.range +
|
|
1283
|
+
visibleInfo.padding.end -
|
|
1284
|
+
1,
|
|
1285
|
+
visibleInfo.endWithPadding + props.keepTraceRange * pageRange
|
|
1286
|
+
),
|
|
1287
|
+
next_item_id,
|
|
1288
|
+
false,
|
|
1289
|
+
permanentItemList
|
|
1290
|
+
);
|
|
1291
|
+
} else {
|
|
1292
|
+
//不做滚动时,保证获焦的item创建
|
|
1293
|
+
pageUpdater.update(
|
|
1294
|
+
templateParser,
|
|
1295
|
+
cur_visible_start,
|
|
1296
|
+
cur_visible_start + visibleInfo.range + visibleInfo.padding.end - 1,
|
|
1297
|
+
next_item_id,
|
|
1298
|
+
false,
|
|
1299
|
+
permanentItemList
|
|
1300
|
+
);
|
|
1201
1301
|
}
|
|
1202
|
-
pageUpdater.update(
|
|
1203
|
-
templateParser,
|
|
1204
|
-
visibleInfo.startWithPadding - props.keepTraceRange * pageRange,
|
|
1205
|
-
Math.min(
|
|
1206
|
-
visibleInfo.startMax +
|
|
1207
|
-
visibleInfo.range +
|
|
1208
|
-
visibleInfo.padding.end -
|
|
1209
|
-
1,
|
|
1210
|
-
visibleInfo.endWithPadding + props.keepTraceRange * pageRange
|
|
1211
|
-
),
|
|
1212
|
-
next_item_id,
|
|
1213
|
-
false,
|
|
1214
|
-
permanentItemList
|
|
1215
|
-
);
|
|
1216
1302
|
pageUpdater.applyTmp();
|
|
1217
1303
|
}
|
|
1218
1304
|
|
|
@@ -1303,40 +1389,50 @@ const _calculateVisibleStart = (target_item, direction) => {
|
|
|
1303
1389
|
];
|
|
1304
1390
|
break;
|
|
1305
1391
|
case SlideSetting.Type.SEAMLESS:
|
|
1306
|
-
if (
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
target_item[size_key] -
|
|
1314
|
-
visibleInfo.range * props.slideSetting.EndPercent;
|
|
1315
|
-
}
|
|
1316
|
-
} else if (direction < 0) {
|
|
1317
|
-
if (
|
|
1318
|
-
target_item[pos_key] <
|
|
1319
|
-
visibleInfo.start +
|
|
1320
|
-
visibleInfo.range * props.slideSetting.StartPercent
|
|
1321
|
-
) {
|
|
1322
|
-
new_visible_start =
|
|
1323
|
-
target_item[pos_key] -
|
|
1324
|
-
visibleInfo.range * props.slideSetting.StartPercent;
|
|
1325
|
-
}
|
|
1392
|
+
if (
|
|
1393
|
+
target_item[size_key] >=
|
|
1394
|
+
visibleInfo.range *
|
|
1395
|
+
(props.slideSetting.EndPercent - props.slideSetting.StartPercent)
|
|
1396
|
+
) {
|
|
1397
|
+
//尺寸较大的item
|
|
1398
|
+
new_visible_start = target_item[center_key] - visibleInfo.range * 0.5;
|
|
1326
1399
|
} else {
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1400
|
+
if (direction > 0) {
|
|
1401
|
+
if (
|
|
1402
|
+
target_item[pos_key] + target_item[size_key] >
|
|
1403
|
+
visibleInfo.start +
|
|
1404
|
+
visibleInfo.range * props.slideSetting.EndPercent
|
|
1405
|
+
) {
|
|
1406
|
+
new_visible_start =
|
|
1407
|
+
target_item[pos_key] +
|
|
1408
|
+
target_item[size_key] -
|
|
1409
|
+
visibleInfo.range * props.slideSetting.EndPercent;
|
|
1410
|
+
}
|
|
1411
|
+
} else if (direction < 0) {
|
|
1412
|
+
if (
|
|
1413
|
+
target_item[pos_key] <
|
|
1414
|
+
visibleInfo.start +
|
|
1415
|
+
visibleInfo.range * props.slideSetting.StartPercent
|
|
1416
|
+
) {
|
|
1417
|
+
new_visible_start =
|
|
1418
|
+
target_item[pos_key] -
|
|
1419
|
+
visibleInfo.range * props.slideSetting.StartPercent;
|
|
1420
|
+
}
|
|
1421
|
+
} else {
|
|
1422
|
+
//不是沿widget方向的移动
|
|
1423
|
+
if (target_item[pos_key] < visibleInfo.start) {
|
|
1424
|
+
new_visible_start =
|
|
1425
|
+
target_item[pos_key] -
|
|
1426
|
+
visibleInfo.range * props.slideSetting.StartPercent;
|
|
1427
|
+
} else if (
|
|
1428
|
+
target_item[pos_key] + target_item[size_key] >
|
|
1429
|
+
visibleInfo.end
|
|
1430
|
+
) {
|
|
1431
|
+
new_visible_start =
|
|
1432
|
+
target_item[pos_key] +
|
|
1433
|
+
target_item[size_key] -
|
|
1434
|
+
visibleInfo.range * props.slideSetting.EndPercent;
|
|
1435
|
+
}
|
|
1340
1436
|
}
|
|
1341
1437
|
}
|
|
1342
1438
|
break;
|
|
@@ -1403,9 +1499,16 @@ const _ifValidEnterRect = (rect_info) => {
|
|
|
1403
1499
|
return rect_info && rect_info.direction && rect_info.rect;
|
|
1404
1500
|
};
|
|
1405
1501
|
|
|
1406
|
-
const _setZIndex = (index, z_index) => {
|
|
1502
|
+
const _setZIndex = (index, z_index, is_focus) => {
|
|
1407
1503
|
if (innerData[index]) {
|
|
1408
|
-
innerData[index].
|
|
1504
|
+
let data = innerData[index].data,
|
|
1505
|
+
i = z_index;
|
|
1506
|
+
if (is_focus && data.focusZIndex >= 0) {
|
|
1507
|
+
i = data.focusZIndex;
|
|
1508
|
+
} else if (data.normalZIndex >= 0) {
|
|
1509
|
+
i = data.normalZIndex;
|
|
1510
|
+
}
|
|
1511
|
+
innerData[index].controller.zIndex = i;
|
|
1409
1512
|
}
|
|
1410
1513
|
};
|
|
1411
1514
|
|
|
@@ -1457,11 +1560,11 @@ const _onSlideEnd = (event) => {
|
|
|
1457
1560
|
};
|
|
1458
1561
|
|
|
1459
1562
|
const _updateFocusItem = () => {
|
|
1460
|
-
_setZIndex(templateParser.FocusIdToIndex(focusId), innerData.length);
|
|
1563
|
+
_setZIndex(templateParser.FocusIdToIndex(focusId), innerData.length, true);
|
|
1461
1564
|
};
|
|
1462
1565
|
|
|
1463
1566
|
const _updateBlurItem = () => {
|
|
1464
|
-
_setZIndex(templateParser.FocusIdToIndex(preFocusId), 0);
|
|
1567
|
+
_setZIndex(templateParser.FocusIdToIndex(preFocusId), 0, false);
|
|
1465
1568
|
};
|
|
1466
1569
|
|
|
1467
1570
|
const _updateFocusByDragInfo = (viewX, viewY) => {
|
|
@@ -1607,21 +1710,23 @@ const _onScroll = () => {
|
|
|
1607
1710
|
|
|
1608
1711
|
//之前rootview相关的代码
|
|
1609
1712
|
const _updatePosition = (x, y, anim_info) => {
|
|
1713
|
+
if (slideLock) return;
|
|
1610
1714
|
if (toRaw(slideDiv.value)) {
|
|
1611
|
-
let
|
|
1715
|
+
let pre_left = toRaw(slideDiv.value).style.left,
|
|
1716
|
+
pre_top = toRaw(slideDiv.value).style.top;
|
|
1612
1717
|
//jsvMaskView的位置更新时会被设置位0,因此不能通过ResetLayoutParams设置位置
|
|
1613
1718
|
slideDivLeft.value = x;
|
|
1614
1719
|
slideDivTop.value = y;
|
|
1615
1720
|
if (anim_info) {
|
|
1616
|
-
let delta_x = Math.abs(
|
|
1617
|
-
let delta_y = Math.abs(
|
|
1721
|
+
let delta_x = Math.abs(pre_left - x);
|
|
1722
|
+
let delta_y = Math.abs(pre_top - y);
|
|
1618
1723
|
let duration = Math.round(
|
|
1619
1724
|
delta_x === 0 ? delta_y / anim_info.speed : delta_x / anim_info.speed
|
|
1620
1725
|
);
|
|
1621
1726
|
let slide_animation = new Forge.TranslateAnimation(
|
|
1622
|
-
|
|
1727
|
+
pre_left - x,
|
|
1623
1728
|
0,
|
|
1624
|
-
|
|
1729
|
+
pre_top - y,
|
|
1625
1730
|
0,
|
|
1626
1731
|
duration,
|
|
1627
1732
|
anim_info.easing
|
|
@@ -1708,7 +1813,8 @@ templateItemAdder = new TemplateItemAdder(
|
|
|
1708
1813
|
dataList,
|
|
1709
1814
|
props.measures,
|
|
1710
1815
|
pageRange,
|
|
1711
|
-
_onTemplateAdd
|
|
1816
|
+
_onTemplateAdd,
|
|
1817
|
+
props.name
|
|
1712
1818
|
);
|
|
1713
1819
|
if (props.onScroll) {
|
|
1714
1820
|
templateItemAdder.tryAddItemByIndex(dataList.length - 1);
|
|
@@ -1740,12 +1846,14 @@ slidePile = new Forge.RectArea(
|
|
|
1740
1846
|
let init_focus_id = 0;
|
|
1741
1847
|
let cur_visible_start = 0;
|
|
1742
1848
|
|
|
1743
|
-
if (props.initFocusId) {
|
|
1849
|
+
if (typeof props.initFocusId == 'number') {
|
|
1744
1850
|
templateItemAdder.tryAddItemById(props.initFocusId);
|
|
1745
1851
|
const item = templateParser.GetItemById(props.initFocusId);
|
|
1746
1852
|
if (item) {
|
|
1747
1853
|
init_focus_id = props.initFocusId;
|
|
1748
|
-
|
|
1854
|
+
if (item.doSlide) {
|
|
1855
|
+
cur_visible_start = _calculateVisibleStart(item, 1);
|
|
1856
|
+
}
|
|
1749
1857
|
}
|
|
1750
1858
|
}
|
|
1751
1859
|
focusId = init_focus_id;
|
|
@@ -34,12 +34,12 @@ const measureObjectCheckMap = {
|
|
|
34
34
|
width: (obj) => {
|
|
35
35
|
if (isNaN(obj.width)) {
|
|
36
36
|
if (isNaN(obj.block?.w)) {
|
|
37
|
+
throw new Error(TAG + "width is not defined");
|
|
38
|
+
} else {
|
|
37
39
|
console.warn(TAG, "key 'block' is deprecated ");
|
|
38
40
|
return integerCheck(obj.blocks.w, () => {
|
|
39
41
|
console.warn(TAG, "width is not integer", obj);
|
|
40
42
|
});
|
|
41
|
-
} else {
|
|
42
|
-
throw new Error(TAG + "width is not definied");
|
|
43
43
|
}
|
|
44
44
|
} else {
|
|
45
45
|
return integerCheck(obj.width, () => {
|
|
@@ -50,12 +50,12 @@ const measureObjectCheckMap = {
|
|
|
50
50
|
height: (obj) => {
|
|
51
51
|
if (isNaN(obj.height)) {
|
|
52
52
|
if (isNaN(obj.block?.h)) {
|
|
53
|
+
throw new Error(TAG + "height is not defined");
|
|
54
|
+
} else {
|
|
53
55
|
console.warn(TAG, "key 'block' is deprecated ");
|
|
54
56
|
return integerCheck(obj.blocks.h, () => {
|
|
55
57
|
console.warn(TAG, "height is not integer", obj);
|
|
56
58
|
});
|
|
57
|
-
} else {
|
|
58
|
-
throw new Error(TAG + "height is not definied");
|
|
59
59
|
}
|
|
60
60
|
} else {
|
|
61
61
|
return integerCheck(obj.height, () => {
|
|
@@ -72,6 +72,26 @@ function measureObjectChecker(obj) {
|
|
|
72
72
|
|
|
73
73
|
function getTemplateItem(measure_obj, data_info) {
|
|
74
74
|
measureObjectChecker(measure_obj);
|
|
75
|
+
|
|
76
|
+
let focusZIndex = -1,
|
|
77
|
+
normalZIndex = -1;
|
|
78
|
+
if (
|
|
79
|
+
typeof measure_obj["zIndex"] != "undefined" &&
|
|
80
|
+
measure_obj["zIndex"] != null
|
|
81
|
+
) {
|
|
82
|
+
if (typeof measure_obj["zIndex"] == "object") {
|
|
83
|
+
if (typeof measure_obj["zIndex"]["focus"] == "number") {
|
|
84
|
+
focusZIndex = measure_obj["zIndex"]["focus"];
|
|
85
|
+
}
|
|
86
|
+
if (typeof measure_obj["zIndex"]["normal"] == "number") {
|
|
87
|
+
normalZIndex = measure_obj["zIndex"]["normal"];
|
|
88
|
+
}
|
|
89
|
+
} else if (typeof measure_obj["zIndex"] == "number") {
|
|
90
|
+
focusZIndex = measure_obj["zIndex"];
|
|
91
|
+
normalZIndex = measure_obj["zIndex"];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
75
95
|
return {
|
|
76
96
|
id: -1,
|
|
77
97
|
index: -1,
|
|
@@ -106,6 +126,8 @@ function getTemplateItem(measure_obj, data_info) {
|
|
|
106
126
|
typeof measure_obj.permanent !== "undefined"
|
|
107
127
|
? measure_obj.permanent
|
|
108
128
|
: false,
|
|
129
|
+
focusZIndex,
|
|
130
|
+
normalZIndex,
|
|
109
131
|
};
|
|
110
132
|
}
|
|
111
133
|
|
|
@@ -867,7 +889,10 @@ class TemplateParser {
|
|
|
867
889
|
item_key_pos = gap_info.startPos;
|
|
868
890
|
item_second_pos = top_fence.AheadOffset;
|
|
869
891
|
} else {
|
|
870
|
-
|
|
892
|
+
throw new Error(
|
|
893
|
+
`${TAG} item size ${item_width}x${item_height} is greater than widget line max ${this._Template.Orient.widthMax}`
|
|
894
|
+
);
|
|
895
|
+
// console.error(TAG, "ERROR: coding error, header full gap fence lost");
|
|
871
896
|
}
|
|
872
897
|
|
|
873
898
|
if (this._Template.Orient.type === VERTICAL) {
|
|
@@ -1846,7 +1871,14 @@ class TemplateParser {
|
|
|
1846
1871
|
}
|
|
1847
1872
|
|
|
1848
1873
|
class TemplateItemAdder {
|
|
1849
|
-
constructor(
|
|
1874
|
+
constructor(
|
|
1875
|
+
template_parser,
|
|
1876
|
+
data,
|
|
1877
|
+
measure_func,
|
|
1878
|
+
page_range,
|
|
1879
|
+
side_effect,
|
|
1880
|
+
id
|
|
1881
|
+
) {
|
|
1850
1882
|
this._TemplateParser = template_parser;
|
|
1851
1883
|
this._Data = data;
|
|
1852
1884
|
this._PageRange = page_range;
|
|
@@ -1859,6 +1891,7 @@ class TemplateItemAdder {
|
|
|
1859
1891
|
this._TemplateParser._Template.Orient.type === HORIZONTAL
|
|
1860
1892
|
? "xPos"
|
|
1861
1893
|
: "yPos";
|
|
1894
|
+
this._ID = id;
|
|
1862
1895
|
}
|
|
1863
1896
|
|
|
1864
1897
|
tryAddItem(cur_item = null, page_num = 1) {
|
|
@@ -1869,15 +1902,23 @@ class TemplateItemAdder {
|
|
|
1869
1902
|
cur_item[this._Key] >= (this._CurPage - 1) * this._PageRange)
|
|
1870
1903
|
) {
|
|
1871
1904
|
while (this._CurIndex < this._Data.length) {
|
|
1872
|
-
|
|
1873
|
-
this.
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
this._CurPage
|
|
1880
|
-
|
|
1905
|
+
try {
|
|
1906
|
+
let item = this._TemplateParser.ParseTemplateItem(
|
|
1907
|
+
this._MeasureFunc(this._Data[this._CurIndex]),
|
|
1908
|
+
this._Data[this._CurIndex]
|
|
1909
|
+
);
|
|
1910
|
+
this._SideEffect?.(item);
|
|
1911
|
+
this._CurIndex++;
|
|
1912
|
+
if (item[this._Key] >= (this._CurPage + page_num) * this._PageRange) {
|
|
1913
|
+
this._CurPage += page_num;
|
|
1914
|
+
break;
|
|
1915
|
+
}
|
|
1916
|
+
} catch (e) {
|
|
1917
|
+
console.error(
|
|
1918
|
+
`MetroWidget: ${this._ID} parse template item ${this._CurIndex} failed. data: `,
|
|
1919
|
+
this._Data
|
|
1920
|
+
);
|
|
1921
|
+
throw e;
|
|
1881
1922
|
}
|
|
1882
1923
|
}
|
|
1883
1924
|
this._TemplateParser.CalculateNeighborWhenAddStop();
|
|
@@ -1899,14 +1940,22 @@ class TemplateItemAdder {
|
|
|
1899
1940
|
let added = false;
|
|
1900
1941
|
while (this._CurIndex <= _index) {
|
|
1901
1942
|
added = true;
|
|
1902
|
-
|
|
1903
|
-
this.
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
this._CurPage
|
|
1943
|
+
try {
|
|
1944
|
+
let item = this._TemplateParser.ParseTemplateItem(
|
|
1945
|
+
this._MeasureFunc(this._Data[this._CurIndex]),
|
|
1946
|
+
this._Data[this._CurIndex]
|
|
1947
|
+
);
|
|
1948
|
+
this._SideEffect?.(item);
|
|
1949
|
+
this._CurIndex++;
|
|
1950
|
+
if (item[this._Key] >= (this._CurPage + 1) * this._PageRange) {
|
|
1951
|
+
this._CurPage++;
|
|
1952
|
+
}
|
|
1953
|
+
} catch (e) {
|
|
1954
|
+
console.error(
|
|
1955
|
+
`MetroWidget: ${this._ID} parse template item ${this._CurIndex} failed. data:`,
|
|
1956
|
+
this._Data
|
|
1957
|
+
);
|
|
1958
|
+
throw e;
|
|
1910
1959
|
}
|
|
1911
1960
|
}
|
|
1912
1961
|
if (added) {
|
|
@@ -1924,16 +1973,24 @@ class TemplateItemAdder {
|
|
|
1924
1973
|
let cur_id = last_id;
|
|
1925
1974
|
while (cur_id < _id && this._CurIndex < this._Data.length) {
|
|
1926
1975
|
added = true;
|
|
1927
|
-
|
|
1928
|
-
this.
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
this._CurPage
|
|
1976
|
+
try {
|
|
1977
|
+
const item = this._TemplateParser.ParseTemplateItem(
|
|
1978
|
+
this._MeasureFunc(this._Data[this._CurIndex]),
|
|
1979
|
+
this._Data[this._CurIndex]
|
|
1980
|
+
);
|
|
1981
|
+
cur_id = item.id;
|
|
1982
|
+
this._SideEffect?.(item);
|
|
1983
|
+
if (item[this._Key] >= (this._CurPage + 1) * this._PageRange) {
|
|
1984
|
+
this._CurPage++;
|
|
1985
|
+
}
|
|
1986
|
+
this._CurIndex++;
|
|
1987
|
+
} catch (e) {
|
|
1988
|
+
console.error(
|
|
1989
|
+
`MetroWidget: ${this._ID} parse template item ${this._CurIndex} failed. data:`,
|
|
1990
|
+
this._Data
|
|
1991
|
+
);
|
|
1992
|
+
throw e;
|
|
1935
1993
|
}
|
|
1936
|
-
this._CurIndex++;
|
|
1937
1994
|
}
|
|
1938
1995
|
if (added) {
|
|
1939
1996
|
this._TemplateParser.CalculateNeighborWhenAddStop();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Author: ChenChanghua
|
|
3
3
|
* @Date: 2020-12-30 14:08:38
|
|
4
4
|
* @LastEditors: ChenChanghua
|
|
5
|
-
* @LastEditTime: 2022-
|
|
5
|
+
* @LastEditTime: 2022-11-09 09:33:15
|
|
6
6
|
* @Description: file content
|
|
7
7
|
*/
|
|
8
8
|
class BaseDispatcher {
|
|
@@ -75,12 +75,11 @@ function getPositionRelativeToView(divElement, targetElement) {
|
|
|
75
75
|
return null;
|
|
76
76
|
}
|
|
77
77
|
let element = divElement;
|
|
78
|
-
const elementLayoutParams = element.jsvMaskView.GetLayoutParams();
|
|
79
78
|
let position = {
|
|
80
79
|
left: 0,
|
|
81
80
|
top: 0,
|
|
82
|
-
width:
|
|
83
|
-
height:
|
|
81
|
+
width: element.style.width,
|
|
82
|
+
height: element.style.height,
|
|
84
83
|
};
|
|
85
84
|
while (element && element !== targetElement) {
|
|
86
85
|
position.left += element.style.left ? element.style.left : 0;
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
* @Author: ChenChanghua
|
|
3
3
|
* @Date: 2021-06-16 10:07:20
|
|
4
4
|
* @LastEditors: ChenChanghua
|
|
5
|
-
* @LastEditTime: 2022-07
|
|
5
|
+
* @LastEditTime: 2022-11-07 14:50:02
|
|
6
6
|
* @Description: file content
|
|
7
7
|
*/
|
|
8
8
|
export * from "./WidgetCommon";
|
|
9
|
-
export * from "./
|
|
9
|
+
export * from "./MetroWidget/Dispatcher";
|
|
10
10
|
|
|
11
11
|
export { default as SimpleWidget } from "./MetroWidget/MetroWidget.vue";
|
|
12
12
|
export { default as MetroWidget } from "./MetroWidget/MetroWidget.vue";
|
|
13
|
+
export { METRO_WIDGET } from "./MetroWidget/Const.js";
|
|
13
14
|
|
|
14
15
|
export { default as JsvFocusBlock } from "./JsvFocusBlock.vue";
|
|
15
16
|
export { jsvCreateFocusManager, useFocusHub } from "./JsvFocusManager";
|