@shijiu/jsview 1.9.719
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 -0
- package/dom/bin/jsview-dom.min.js +1 -0
- package/dom/bin/jsview-engine-js-browser.min.js +1 -0
- package/dom/bin/jsview-forge-define.min.js +1 -0
- package/dom/browser-root-style.css +21 -0
- package/dom/jsv-browser-debug-dom.js +8 -0
- package/dom/jsv-dom.js +6 -0
- package/dom/jsv-engine-js-browser.js +6 -0
- package/dom/jsv-forge-define.js +6 -0
- package/dom/jsview-dom/README.md +5 -0
- package/dom/jsview-dom/package-lock.json-perfect +3898 -0
- package/dom/jsview-dom/package.json +23 -0
- package/dom/jsview-dom/rollup/browser-debug-dom.rollup.config.js +15 -0
- package/dom/jsview-dom/rollup/dom.rollup.config.js +14 -0
- package/dom/jsview-dom/rollup/engine-js-browser.rollup.config.js +14 -0
- package/dom/jsview-dom/rollup/forge-define.rollup.config.js +14 -0
- package/dom/jsview-dom/scripts/release_dist.sh +36 -0
- package/dom/jsview-dom/src/dom-browser-hook/HookDocument.js +118 -0
- package/dom/jsview-dom/src/dom-browser-hook/OriginDocument.js +19 -0
- package/dom/jsview-dom/src/dom-browser-hook/StyleFormatCheck.js +559 -0
- package/dom/jsview-dom/src/dom-browser-hook/index.js +6 -0
- package/dom/jsview-dom/src/dom-wrapper/ForgeExtension.js +226 -0
- package/dom/jsview-dom/src/dom-wrapper/JsViewForgeApp.js +85 -0
- package/dom/jsview-dom/src/dom-wrapper/JsViewProxy.js +51 -0
- package/dom/jsview-dom/src/dom-wrapper/event/AnimationEvent.js +7 -0
- package/dom/jsview-dom/src/dom-wrapper/event/Event.js +12 -0
- package/dom/jsview-dom/src/dom-wrapper/event/FocusEvent.js +9 -0
- package/dom/jsview-dom/src/dom-wrapper/event/KeyboardEvent.js +43 -0
- package/dom/jsview-dom/src/dom-wrapper/event/LoadEvent.js +8 -0
- package/dom/jsview-dom/src/dom-wrapper/index.js +16 -0
- package/dom/jsview-dom/src/dom-wrapper/node/AnchorElement.js +24 -0
- package/dom/jsview-dom/src/dom-wrapper/node/AudioElement.js +60 -0
- package/dom/jsview-dom/src/dom-wrapper/node/Comment.js +10 -0
- package/dom/jsview-dom/src/dom-wrapper/node/DivElement.js +498 -0
- package/dom/jsview-dom/src/dom-wrapper/node/Document.js +274 -0
- package/dom/jsview-dom/src/dom-wrapper/node/Element.js +852 -0
- package/dom/jsview-dom/src/dom-wrapper/node/FDivElement.js +48 -0
- package/dom/jsview-dom/src/dom-wrapper/node/HeadElement.js +47 -0
- package/dom/jsview-dom/src/dom-wrapper/node/ImageElement.js +203 -0
- package/dom/jsview-dom/src/dom-wrapper/node/JsvAudioTrackElement.js +22 -0
- package/dom/jsview-dom/src/dom-wrapper/node/JsvElement.js +40 -0
- package/dom/jsview-dom/src/dom-wrapper/node/LinkElement.js +48 -0
- package/dom/jsview-dom/src/dom-wrapper/node/MediaElement.js +230 -0
- package/dom/jsview-dom/src/dom-wrapper/node/Node.js +178 -0
- package/dom/jsview-dom/src/dom-wrapper/node/SVGElement.js +9 -0
- package/dom/jsview-dom/src/dom-wrapper/node/ScriptElement.js +45 -0
- package/dom/jsview-dom/src/dom-wrapper/node/StyleElement.js +33 -0
- package/dom/jsview-dom/src/dom-wrapper/node/StyleElementCache.js +41 -0
- package/dom/jsview-dom/src/dom-wrapper/node/Text.js +22 -0
- package/dom/jsview-dom/src/dom-wrapper/node/UnknownElement.js +4 -0
- package/dom/jsview-dom/src/dom-wrapper/node/VideoElement.js +237 -0
- package/dom/jsview-dom/src/dom-wrapper/style/BorderImage.js +25 -0
- package/dom/jsview-dom/src/dom-wrapper/style/Inset.js +26 -0
- package/dom/jsview-dom/src/dom-wrapper/style/JsvStyleVariable.js +65 -0
- package/dom/jsview-dom/src/dom-wrapper/style/KeyframeRule.js +11 -0
- package/dom/jsview-dom/src/dom-wrapper/style/StyleDeclaration.js +609 -0
- package/dom/jsview-dom/src/dom-wrapper/style/StyleSheet.js +51 -0
- package/dom/jsview-dom/src/dom-wrapper/style/StyleValue.js +385 -0
- package/dom/jsview-dom/src/dom-wrapper/style/TextStylePackMap.js +43 -0
- package/dom/jsview-dom/src/dom-wrapper/style/URL.js +144 -0
- package/dom/jsview-dom/src/dom-wrapper/utils/EventHandler.js +42 -0
- package/dom/jsview-dom/src/dom-wrapper/utils/FDivRoot.js +86 -0
- package/dom/jsview-dom/src/dom-wrapper/utils/JsvLazySyncCache.js +64 -0
- package/dom/jsview-dom/src/dom-wrapper/utils/Log.js +42 -0
- package/dom/jsview-dom/src/dom-wrapper/utils/MutationObserver.js +32 -0
- package/dom/jsview-dom/src/dom-wrapper/utils/focusableNode.js +715 -0
- package/dom/jsview-dom/src/engine-js/ForgeDefine.js +8 -0
- package/dom/jsview-dom/src/engine-js/ForgeExtensionDefine.js +14 -0
- package/dom/jsview-dom/src/engine-js/browser/PlatformUtils.js +100 -0
- package/dom/jsview-dom/src/engine-js/browser/animation_base.js +313 -0
- package/dom/jsview-dom/src/engine-js/browser/animation_keyframe.js +64 -0
- package/dom/jsview-dom/src/engine-js/browser/animation_progress.js +287 -0
- package/dom/jsview-dom/src/engine-js/browser/animation_proxy.js +906 -0
- package/dom/jsview-dom/src/engine-js/browser/apic_decoder/demux.js +143 -0
- package/dom/jsview-dom/src/engine-js/browser/apic_decoder/gifDecoder.js +12 -0
- package/dom/jsview-dom/src/engine-js/browser/apic_decoder/libwebp-0.6.0.min.js +160 -0
- package/dom/jsview-dom/src/engine-js/browser/console_log.js +25 -0
- package/dom/jsview-dom/src/engine-js/browser/dynamic_key_frames.js +95 -0
- package/dom/jsview-dom/src/engine-js/browser/easing.js +114 -0
- package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/element_transform.js +122 -0
- package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/gjk.js +450 -0
- package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/mat.js +102 -0
- package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/range_model.js +296 -0
- package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/test_collide.js +10 -0
- package/dom/jsview-dom/src/engine-js/browser/index.js +38 -0
- package/dom/jsview-dom/src/engine-js/browser/latex_parse.js +336 -0
- package/dom/jsview-dom/src/engine-js/browser/layout_params.js +113 -0
- package/dom/jsview-dom/src/engine-js/browser/layout_view.js +3545 -0
- package/dom/jsview-dom/src/engine-js/browser/layout_view_debug.js +15 -0
- package/dom/jsview-dom/src/engine-js/browser/media.js +379 -0
- package/dom/jsview-dom/src/engine-js/browser/page_base.js +941 -0
- package/dom/jsview-dom/src/engine-js/browser/particle_view.js +526 -0
- package/dom/jsview-dom/src/engine-js/browser/platform_timer.js +61 -0
- package/dom/jsview-dom/src/engine-js/browser/react_utils.js +5 -0
- package/dom/jsview-dom/src/engine-js/browser/rect_utils.js +91 -0
- package/dom/jsview-dom/src/engine-js/browser/render_bridge.js +128 -0
- package/dom/jsview-dom/src/engine-js/browser/render_texture_proxy.js +155 -0
- package/dom/jsview-dom/src/engine-js/browser/renderer_deprecated.js +75 -0
- package/dom/jsview-dom/src/engine-js/browser/sound_pool.js +139 -0
- package/dom/jsview-dom/src/engine-js/browser/steps_animation.js +192 -0
- package/dom/jsview-dom/src/engine-js/browser/text_style_cache.js +454 -0
- package/dom/jsview-dom/src/engine-js/browser/text_utils.js +299 -0
- package/dom/jsview-dom/src/engine-js/browser/text_view.js +428 -0
- package/dom/jsview-dom/src/engine-js/browser/texture_manager.js +1060 -0
- package/dom/jsview-dom/src/engine-js/browser/url.js +69 -0
- package/dom/jsview-dom/src/engine-js/browser/velocity.js +40 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/autofroze_sensor.js +77 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/drag_impact_sensor.js +67 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/impact_sensor.js +98 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/impact_sensor_callback.js +21 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/impact_sensor_manager.js +24 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/index.js +9 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/view_sensor.js +268 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/view_sensor_manager.js +84 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/visible_sensor.js +213 -0
- package/dom/jsview-dom/src/engine-js/browser/view_store.js +41 -0
- package/dom/jsview-dom/src/engine-js/index.js +2 -0
- package/dom/jsview-dom/src/engine-js/native/README.md +1 -0
- package/dom/target_core_revision.mjs +15 -0
- package/index.js +0 -0
- package/loader/header_script_loader.js +134 -0
- package/loader/jsview-main.js +42 -0
- package/loader/jsview.config.default.js +37 -0
- package/loader/jsview.default.config.js +37 -0
- package/loader/loader.js +183 -0
- package/loader/loader_webkit.js +40 -0
- package/package.json +31 -0
- package/patches/node_modules/@vitejs/plugin-react/dist/index.cjs +520 -0
- package/patches/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +17609 -0
- package/patches/node_modules/@vue/compiler-sfc/dist/jsview-css-to-js.js +335 -0
- package/patches/node_modules/@vue/compiler-sfc/dist/jsview-style-format.js +446 -0
- package/patches/node_modules/@vue/compiler-sfc/dist/jsview-style-types.js +91 -0
- package/patches/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js +8038 -0
- package/patches/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js +1700 -0
- package/patches/node_modules/postcss-js/objectifier.js +90 -0
- package/patches/node_modules/vite/dist/node/chunks/dep-0fc8e132.js +63175 -0
- package/patches/node_modules/vite/dist/node/jsview-react.vite.config.js +7 -0
- package/patches/node_modules/vite/dist/node/jsview-vue.vite.config.js +7 -0
- package/patches/node_modules/vite/dist/node/jsview.vite.config.js +56 -0
- package/patches/node_modules/vue-router/dist/vue-router.mjs +3595 -0
- package/tools/common.js +58 -0
- package/tools/jsview-jsmap-serve.js +105 -0
- package/tools/jsview-post-build.js +184 -0
- package/tools/jsview-post-install-react.js +13 -0
- package/tools/jsview-post-install-vue.js +16 -0
- package/tools/jsview-post-install.js +116 -0
- package/tools/jsview-run-android.js +67 -0
- package/tsconfig.json +34 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by luocf on 2020/1/17.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/* eslint-disable no-extra-boolean-cast */
|
|
6
|
+
var ForgeExtension = {}
|
|
7
|
+
if (!!window.JsView) {
|
|
8
|
+
if (!(window.JsView.Dom&&window.JsView.Dom.Extension)) {
|
|
9
|
+
window.JsView.Dom.Extension = ForgeExtension
|
|
10
|
+
}
|
|
11
|
+
ForgeExtension = window.JsView.Dom.Extension
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default ForgeExtension
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
2
|
+
class PlatformUtils {
|
|
3
|
+
static getTextPixelWith(text, fontStyle) {
|
|
4
|
+
if (PlatformUtils.sCanvas === null) {
|
|
5
|
+
PlatformUtils.sCanvas = window.originDocument.createElement("canvas"); // 创建 canvas 画布
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const context = PlatformUtils.sCanvas.getContext("2d"); // 获取 canvas 绘图上下文环境
|
|
9
|
+
context.font = fontStyle; // 设置字体样式,使用前设置好对应的 font 样式才能准确获取文字的像素长度
|
|
10
|
+
const dimension = context.measureText(text); // 测量文字
|
|
11
|
+
return Math.ceil(dimension.width);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static GetTextWidth(font_params) {
|
|
15
|
+
let bold = "";
|
|
16
|
+
if (font_params.bold) {
|
|
17
|
+
bold = "bold";
|
|
18
|
+
}
|
|
19
|
+
let italic = "";
|
|
20
|
+
if (font_params.italic) {
|
|
21
|
+
italic = "italic";
|
|
22
|
+
}
|
|
23
|
+
return this.getTextPixelWith(font_params.str, `${bold} ${italic} ${font_params.size}px ${font_params.font}`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static GetTextRect(str, max_rect, font_params, text_attr, line_height) {
|
|
27
|
+
const rows = Math.ceil((font_params.size * str.length) / max_rect.width);
|
|
28
|
+
let height = rows * line_height;
|
|
29
|
+
if (height > max_rect.height) {
|
|
30
|
+
height = max_rect.height;
|
|
31
|
+
}
|
|
32
|
+
const ret_json = {
|
|
33
|
+
width: max_rect.width,
|
|
34
|
+
height
|
|
35
|
+
};
|
|
36
|
+
return ret_json;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static GetCursorOffset(str, max_rect, font_params, text_attr, line_height, pos_x, pos_y) {
|
|
40
|
+
// TODO 目前只考虑单行
|
|
41
|
+
let bold = "";
|
|
42
|
+
if (font_params.bold) {
|
|
43
|
+
bold = "bold";
|
|
44
|
+
}
|
|
45
|
+
let italic = "";
|
|
46
|
+
if (font_params.italic) {
|
|
47
|
+
italic = "italic";
|
|
48
|
+
}
|
|
49
|
+
let cursor_offset = 0;
|
|
50
|
+
if (font_params.alignment === "right") {
|
|
51
|
+
const width = this.getTextPixelWith(str, `${bold} ${italic} ${font_params.size}px ${font_params.font}`);
|
|
52
|
+
pos_x -= (max_rect.width - width);
|
|
53
|
+
if (pos_x < 0) {
|
|
54
|
+
pos_x = 0;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let sub_width = 0;
|
|
59
|
+
while (pos_x >= sub_width) {
|
|
60
|
+
if (cursor_offset === str.length) {
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
sub_width = this.getTextPixelWith(str.substr(0, cursor_offset + 1), `${bold} ${italic} ${font_params.size}px ${font_params.font}`);
|
|
64
|
+
if (pos_x >= sub_width) {
|
|
65
|
+
cursor_offset++;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return cursor_offset;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
static GetCursorPosition(str, max_rect, font_params, text_attr, line_height, cursor_offset) {
|
|
73
|
+
// TODO 目前只考虑单行
|
|
74
|
+
let bold = "";
|
|
75
|
+
if (font_params.bold) {
|
|
76
|
+
bold = "bold";
|
|
77
|
+
}
|
|
78
|
+
let italic = "";
|
|
79
|
+
if (font_params.italic) {
|
|
80
|
+
italic = "italic";
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
let width = 0;
|
|
84
|
+
let sub_str = str;
|
|
85
|
+
if (cursor_offset < str.length) {
|
|
86
|
+
sub_str = sub_str.substr(0, cursor_offset);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
width = this.getTextPixelWith(sub_str, `${bold} ${italic} ${font_params.size}px ${font_params.font}`);
|
|
90
|
+
if (font_params.alignment === "right") {
|
|
91
|
+
// 总长度
|
|
92
|
+
const total_width = this.getTextPixelWith(str, `${bold} ${italic} ${font_params.size}px ${font_params.font}`);
|
|
93
|
+
width = max_rect.width - total_width + width;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return { x: width, y: 0 };
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
PlatformUtils.sCanvas = null;
|
|
100
|
+
window.PlatformUtils = PlatformUtils;
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
2
|
+
import Forge from "../ForgeDefine";
|
|
3
|
+
|
|
4
|
+
let sIdTokenGenerator = 0;
|
|
5
|
+
|
|
6
|
+
class AnimationBase {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.IdToken = sIdTokenGenerator++;
|
|
9
|
+
this._AttachedGroup = null;
|
|
10
|
+
this.AnimationListenerObj = null;
|
|
11
|
+
this._AnimationClose = false;
|
|
12
|
+
this._LayoutViewRef = null;
|
|
13
|
+
this._IsTextureAnim = false;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 设置动画起始/结束的监听回调
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
* @func SetAnimationListener
|
|
21
|
+
* @memberof Forge.AnimationBase
|
|
22
|
+
* @instance
|
|
23
|
+
* @param {Forge.AnimationListener} listener 动画起始/结束的监听回调
|
|
24
|
+
* */
|
|
25
|
+
SetAnimationListener(listener) {
|
|
26
|
+
this.AnimationListenerObj = listener;
|
|
27
|
+
this.OnNewListener(listener);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 追加动画起始/结束的监听回调
|
|
32
|
+
*
|
|
33
|
+
* @public
|
|
34
|
+
* @func AddAnimationListener
|
|
35
|
+
* @memberof Forge.AnimationBase
|
|
36
|
+
* @instance
|
|
37
|
+
* @param {Forge.AnimationListener} listener 动画起始/结束的监听回调
|
|
38
|
+
* */
|
|
39
|
+
AddAnimationListener(listener) {
|
|
40
|
+
if (this.AnimationListenerObj) {
|
|
41
|
+
listener.AddInherit(this.AnimationListenerObj);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
this.AnimationListenerObj = listener;
|
|
45
|
+
this.OnNewListener(listener);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
OnNewListener(listener) {
|
|
49
|
+
// Can override if needed
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 获得当前动画的启动/结束监听接口
|
|
54
|
+
*
|
|
55
|
+
* @public
|
|
56
|
+
* @func GetAnimationListener
|
|
57
|
+
* @memberof Forge.AnimationBase
|
|
58
|
+
* @instance
|
|
59
|
+
* @return {Forge.AnimationListener} 动画起始/结束的监听回调
|
|
60
|
+
* */
|
|
61
|
+
GetAnimationListener() {
|
|
62
|
+
return this.AnimationListenerObj;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// public from customer
|
|
66
|
+
Cancel(by_other_animation) {
|
|
67
|
+
if (this._LayoutViewRef) {
|
|
68
|
+
this._LayoutViewRef.DetachAnimation(this);
|
|
69
|
+
}
|
|
70
|
+
const listener = this.AnimationListenerObj;
|
|
71
|
+
if (listener && listener.OnAnimationEnd && !this._AnimationClose) {
|
|
72
|
+
this._AnimationClose = true;
|
|
73
|
+
listener.OnAnimationEnd(false);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (this._AttachedGroup) {
|
|
77
|
+
let cancel_whole_group = true;
|
|
78
|
+
if (by_other_animation) {
|
|
79
|
+
cancel_whole_group = (by_other_animation._AttachedGroup !== this._AttachedGroup);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (cancel_whole_group) {
|
|
83
|
+
this._AttachedGroup.CancelFromInternalAnimation(this);
|
|
84
|
+
this._AttachedGroup = null;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 将当前动画加入动画组
|
|
91
|
+
* hide public
|
|
92
|
+
*
|
|
93
|
+
* @func AttachToGroup
|
|
94
|
+
* @memberof Forge.AnimationBase
|
|
95
|
+
* @instance
|
|
96
|
+
* @param {Forge.AnimationGroup} group 要加入的动画组
|
|
97
|
+
* */
|
|
98
|
+
AttachToGroup(group) {
|
|
99
|
+
if (this._AttachedGroup !== null) {
|
|
100
|
+
Forge.ThrowError("ERROR: In TransformAnimation.AttachToGroup(), animation already attached to other group");
|
|
101
|
+
}
|
|
102
|
+
this._AttachedGroup = group;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 从动画组脱离
|
|
107
|
+
* hide public
|
|
108
|
+
*
|
|
109
|
+
* @func RemoveFromGroup
|
|
110
|
+
* @memberof Forge.AnimationBase
|
|
111
|
+
* @instance
|
|
112
|
+
* */
|
|
113
|
+
RemoveFromGroup() {
|
|
114
|
+
this._AttachedGroup = null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// hide public
|
|
118
|
+
AsTextureAnimation() {
|
|
119
|
+
this._IsTextureAnim = true;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
Start(layout_view) {
|
|
123
|
+
this._LayoutViewRef = layout_view;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
SetCannotDisable(can_disable) {
|
|
127
|
+
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// hide public
|
|
131
|
+
OnStart() {
|
|
132
|
+
const listener = this.AnimationListenerObj;
|
|
133
|
+
if (listener && listener.OnAnimationStart) {
|
|
134
|
+
listener.OnAnimationStart();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// hide public
|
|
139
|
+
OnEnd(keep_animation) {
|
|
140
|
+
if (this._LayoutViewRef && !keep_animation) {
|
|
141
|
+
this._LayoutViewRef.DetachAnimation(this);
|
|
142
|
+
this._LayoutViewRef = null;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const listener = this.AnimationListenerObj;
|
|
146
|
+
if (listener && listener.OnAnimationEnd && !this._AnimationClose) {
|
|
147
|
+
this._AnimationClose = true;
|
|
148
|
+
listener.OnAnimationEnd(true);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// hide public
|
|
153
|
+
OnRepeatEvent() {
|
|
154
|
+
const listener = this.AnimationListenerObj;
|
|
155
|
+
if (listener && listener.OnAnimRepeat) {
|
|
156
|
+
listener.OnAnimRepeat();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// hide public
|
|
161
|
+
OnViewHide() {
|
|
162
|
+
const listener = this.AnimationListenerObj;
|
|
163
|
+
if (listener && listener.OnViewNoVisible) {
|
|
164
|
+
listener.OnViewNoVisible();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// hide public
|
|
169
|
+
OnFinalProgress(progress) {
|
|
170
|
+
const listener = this.AnimationListenerObj;
|
|
171
|
+
if (listener && listener.OnAnimFinal) {
|
|
172
|
+
listener.OnAnimFinal(progress);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
OnAnimAdvance(progress) {
|
|
177
|
+
const listener = this.AnimationListenerObj;
|
|
178
|
+
if (listener && listener.OnAnimAdvance) {
|
|
179
|
+
listener.OnAnimAdvance(progress);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
Forge.AnimationBase = AnimationBase;
|
|
184
|
+
|
|
185
|
+
class AnimationListener {
|
|
186
|
+
/**
|
|
187
|
+
* 监听动画启动和结束时间的接口
|
|
188
|
+
*
|
|
189
|
+
* @public
|
|
190
|
+
* @constructor Forge.AnimationListener
|
|
191
|
+
* @author donglin donglin.lu@qcast.cn
|
|
192
|
+
* @param {function} on_start 监听动画启动事件(无参数)
|
|
193
|
+
* @param {function} on_end 监听动画结束事件(无参数)
|
|
194
|
+
* @param {function} on_view_hide 当更新过程中检测到动画对应的View已经不可见的回调<br>
|
|
195
|
+
* 需要和LayoutView.OnDrawResumed(callback)配合使用<br>
|
|
196
|
+
* 参数(LayoutView:对象View, TransformAnimation:监听的动画句柄)
|
|
197
|
+
* */
|
|
198
|
+
constructor(on_start, on_end, on_view_hide) {
|
|
199
|
+
this.OnAnimationStart = on_start;
|
|
200
|
+
this._OnAnimationStart = on_start;
|
|
201
|
+
this.OnAnimationEnd = on_end;
|
|
202
|
+
this._OnAnimationEnd = on_end;
|
|
203
|
+
this.OnViewNoVisible = on_view_hide;
|
|
204
|
+
this._OnViewNoVisible = on_view_hide;
|
|
205
|
+
this.OnAnimFinal = null;
|
|
206
|
+
this._OnAnimFinal = null;
|
|
207
|
+
this.OnAnimRepeat = null;
|
|
208
|
+
this._OnAnimRepeat = null;
|
|
209
|
+
this._AttachedGroup = null;
|
|
210
|
+
this._InheritListener = [];
|
|
211
|
+
this._OnAnimAdvance = null;
|
|
212
|
+
this.OnAnimAdvance = null;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
OnStart(on_start) {
|
|
216
|
+
this._OnAnimationStart = on_start;
|
|
217
|
+
this.OnAnimationStart = on_start;
|
|
218
|
+
return this;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
OnEnd(on_end) {
|
|
222
|
+
this._OnAnimationEnd = on_end;
|
|
223
|
+
this.OnAnimationEnd = on_end;
|
|
224
|
+
return this;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
OnAdvance(on_advance) {
|
|
228
|
+
this._OnAnimAdvance = on_advance;
|
|
229
|
+
this.OnAnimAdvance = on_advance;
|
|
230
|
+
return this;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
OnFinalProgress(on_final) {
|
|
234
|
+
this._OnAnimFinal = on_final;
|
|
235
|
+
this.OnAnimFinal = on_final;
|
|
236
|
+
return this;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
OnRepeat(on_repeat) {
|
|
240
|
+
this._OnAnimRepeat = on_repeat;
|
|
241
|
+
this.OnAnimRepeat = on_repeat;
|
|
242
|
+
return this;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* 添加继承的监听者,当本监听接口被调用后,会继续调用继承者的监听接口
|
|
247
|
+
*
|
|
248
|
+
* @public
|
|
249
|
+
* @param {Forge.AnimationListener} inherit_listener 继承的监听者
|
|
250
|
+
* */
|
|
251
|
+
AddInherit(inherit_listener) {
|
|
252
|
+
if (!inherit_listener) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (this._InheritListener.length === 0) {
|
|
257
|
+
// Init for first inherit
|
|
258
|
+
const that = this;
|
|
259
|
+
this.OnAnimationStart = function() {
|
|
260
|
+
if (that._OnAnimationStart) that._OnAnimationStart();
|
|
261
|
+
for (let i = 0; i < that._InheritListener.length; i++) {
|
|
262
|
+
if (that._InheritListener[i].OnAnimationStart) {
|
|
263
|
+
that._InheritListener[i].OnAnimationStart();
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
this.OnAnimationEnd = function(normal_end) {
|
|
268
|
+
if (that._OnAnimationEnd) that._OnAnimationEnd(normal_end);
|
|
269
|
+
for (let i = 0; i < that._InheritListener.length; i++) {
|
|
270
|
+
if (that._InheritListener[i].OnAnimationEnd) {
|
|
271
|
+
that._InheritListener[i].OnAnimationEnd(normal_end);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
this.OnViewNoVisible = function() {
|
|
276
|
+
if (that._OnViewNoVisible) that._OnViewNoVisible();
|
|
277
|
+
for (let i = 0; i < that._InheritListener.length; i++) {
|
|
278
|
+
if (that._InheritListener[i].OnViewNoVisible) {
|
|
279
|
+
that._InheritListener[i].OnViewNoVisible();
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
this.OnAnimFinal = function(progress) {
|
|
284
|
+
if (that._OnAnimFinal) that._OnAnimFinal(progress);
|
|
285
|
+
for (let i = 0; i < that._InheritListener.length; i++) {
|
|
286
|
+
if (that._InheritListener[i].OnAnimFinal) {
|
|
287
|
+
that._InheritListener[i].OnAnimFinal(progress);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
this.OnAnimRepeat = function() {
|
|
292
|
+
if (that._OnAnimRepeat) that._OnAnimRepeat();
|
|
293
|
+
for (let i = 0; i < that._InheritListener.length; i++) {
|
|
294
|
+
if (that._InheritListener[i].OnAnimRepeat) {
|
|
295
|
+
that._InheritListener[i].OnAnimRepeat();
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
this.OnAnimAdvance = function() {
|
|
301
|
+
if (that._OnAnimAdvance) that._OnAnimAdvance();
|
|
302
|
+
for (let i = 0; i < that._InheritListener.length; i++) {
|
|
303
|
+
if (that._InheritListener[i].OnAnimAdvance) {
|
|
304
|
+
that._InheritListener[i].OnAnimAdvance();
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
this._InheritListener.push(inherit_listener);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
Forge.AnimationListener = AnimationListener;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by ludl on 6/11/20.
|
|
3
|
+
*/
|
|
4
|
+
// 工具类,用于将Animation配置转换成KeyFrame
|
|
5
|
+
import Forge from "../ForgeDefine";
|
|
6
|
+
import { getKeyFramesGroup } from "./dynamic_key_frames";
|
|
7
|
+
|
|
8
|
+
let sKeyFrameControl = null;
|
|
9
|
+
function getStaticFrameControl() {
|
|
10
|
+
if (sKeyFrameControl === null) {
|
|
11
|
+
sKeyFrameControl = getKeyFramesGroup();
|
|
12
|
+
}
|
|
13
|
+
return sKeyFrameControl;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function _ConvertTimingFunc(easing_info) {
|
|
17
|
+
let timing_function = "linear";
|
|
18
|
+
if (easing_info && typeof easing_info.T !== "undefined") {
|
|
19
|
+
switch (easing_info.T) {
|
|
20
|
+
case Forge.EasingTypeIn:
|
|
21
|
+
timing_function = "ease-in";
|
|
22
|
+
break;
|
|
23
|
+
case Forge.EasingTypeOut:
|
|
24
|
+
timing_function = "ease-out";
|
|
25
|
+
break;
|
|
26
|
+
case Forge.EasingTypeInOut:
|
|
27
|
+
timing_function = "ease-in-out";
|
|
28
|
+
break;
|
|
29
|
+
case Forge.EasingTypeBezier:
|
|
30
|
+
timing_function = `cubic-bezier(${easing_info.St.X1},${easing_info.St.Y1},${easing_info.St.X2},${easing_info.St.Y2})`;
|
|
31
|
+
break;
|
|
32
|
+
case Forge.EasingTypeSteps:
|
|
33
|
+
timing_function = `steps(${easing_info.St.S},${easing_info.St.T === 0 ? "start" : "end"})`;
|
|
34
|
+
break;
|
|
35
|
+
case Forge.EasingTypeBlink:
|
|
36
|
+
case Forge.EasingTypeDeceleration:
|
|
37
|
+
default:
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return timing_function;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// 将Forge.AnimationDelegate信息转化成style.animation的填写内容
|
|
45
|
+
function animationToStyle(animation_ref, keyframe_name) {
|
|
46
|
+
const repeat = (animation_ref.repeatTimes === -1 ? "infinite" : animation_ref.repeatTimes);
|
|
47
|
+
let timing_func = "linear";
|
|
48
|
+
if (animation_ref.easing) {
|
|
49
|
+
timing_func = _ConvertTimingFunc(animation_ref.easing);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const style_animation = `${keyframe_name} ${animation_ref.duration / 1000}s ${
|
|
53
|
+
timing_func} ${animation_ref.delayedTime / 1000}s ${
|
|
54
|
+
repeat}`;
|
|
55
|
+
// console.log(`animationToStyle style_anim:${style_animation}`);
|
|
56
|
+
|
|
57
|
+
return style_animation;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export {
|
|
61
|
+
getStaticFrameControl,
|
|
62
|
+
animationToStyle,
|
|
63
|
+
_ConvertTimingFunc as convertTimingFunc,
|
|
64
|
+
};
|