Commit 6e583a84 authored by rockyl's avatar rockyl

修复图片和文本的相对布局的问题

增加Event.WINDOW_VISIBILITY_CHANGE事件表示页面可见性变化的时候的事件
parent 4644465a
This diff is collapsed.
This diff is collapsed.
{"id":"engine","url":"engine.8ae778db8ef99e121b1d622a45079bb758d196e1.js"} {"id":"engine","url":"engine.cba09e24bd26909e1a67685a889d4799f4c2597a.js"}
\ No newline at end of file \ No newline at end of file
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
}, },
"devDependencies": { "devDependencies": {
"dts-bundle": "^0.7.3", "dts-bundle": "^0.7.3",
"dts-bundle-generator": "^4.3.0",
"glob": "^7.1.6", "glob": "^7.1.6",
"rollup-plugin-commonjs": "^10.1.0", "rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0", "rollup-plugin-node-resolve": "^5.2.0",
...@@ -29,9 +30,8 @@ ...@@ -29,9 +30,8 @@
"build:upload": "rm -rf dist&&yarn build:prod && yarn preprocess && ali-oss-publish -c oss.config.js -e dist", "build:upload": "rm -rf dist&&yarn build:prod && yarn preprocess && ali-oss-publish -c oss.config.js -e dist",
"build:debug": "rm -rf dist&&yarn build && yarn preprocess && ali-oss-publish -c oss.config.js -e dist", "build:debug": "rm -rf dist&&yarn build && yarn preprocess && ali-oss-publish -c oss.config.js -e dist",
"ts": "dts-bundle --name engine --main types/src/index.d.ts --out ../../dist/index.d.ts", "ts": "dts-bundle --name engine --main types/src/index.d.ts --out ../../dist/index.d.ts",
"test": "echo \"Error: no test specified\" && exit 1", "token": "uglifyjs -m -c -o px-token.min.js px-token.js",
"mergeDts": "node scripts/mergeDts.js", "dts": "dts-bundle-generator -o types.d.ts src/index.ts"
"token": "uglifyjs -m -c -o px-token.min.js px-token.js"
}, },
"author": "", "author": "",
"license": "ISC" "license": "ISC"
......
...@@ -250,6 +250,12 @@ export class Event extends HashObject { ...@@ -250,6 +250,12 @@ export class Event extends HashObject {
* @type {string} * @type {string}
*/ */
public static UPDATE_DATA: string = "UPDATE_DATA"; public static UPDATE_DATA: string = "UPDATE_DATA";
/**
* 页面可见性变化
*/
public static WINDOW_VISIBILITY_CHANGE: string = 'window-visibility-change';
/** /**
* 事件类型名 * 事件类型名
* @property type * @property type
......
This diff is collapsed.
...@@ -91,7 +91,11 @@ class AlignManager { ...@@ -91,7 +91,11 @@ class AlignManager {
} else { } else {
// 先设置下自己的 width // 先设置下自己的 width
toBoolean(percentWidth) && (tW_Z = that.width = pW_Z * percentWidth / 100); if(toBoolean(percentWidth)){
tW_Z = that.width = pW_Z * percentWidth / 100
}else{
tW_Z = that.width;
}
// 先考虑 horizonCenter 属性 // 先考虑 horizonCenter 属性
if (toBoolean(horizonCenter)) { if (toBoolean(horizonCenter)) {
...@@ -120,7 +124,11 @@ class AlignManager { ...@@ -120,7 +124,11 @@ class AlignManager {
} else { } else {
// 先设置下自己的 height // 先设置下自己的 height
toBoolean(percentHeight) && (tH_Z = that.height = pH_Z * percentHeight / 100); if(toBoolean(percentHeight)){
tH_Z = that.height = pH_Z * percentHeight / 100
}else{
tH_Z = that.height;
}
// 先考虑 horizonCenter 属性 // 先考虑 horizonCenter 属性
if (toBoolean(verticalCenter)) { if (toBoolean(verticalCenter)) {
......
...@@ -108,4 +108,10 @@ export class Image extends Sprite implements IUIComponent { ...@@ -108,4 +108,10 @@ export class Image extends Sprite implements IUIComponent {
private onDataMutated(e = null) { private onDataMutated(e = null) {
this._setSourceDirect(dataCenter.formatString(this._originText, this._escapes)); this._setSourceDirect(dataCenter.formatString(this._originText, this._escapes));
} }
_onTextureUpdate() {
super._onTextureUpdate();
this.dispatchEvent(Event.MAYBE_ALIGN);
}
} }
...@@ -44,6 +44,13 @@ function instantiateView(config) { ...@@ -44,6 +44,13 @@ function instantiateView(config) {
if (children && children.length > 0) { if (children && children.length > 0) {
for (let childConfig of children) { for (let childConfig of children) {
if(childConfig.type=="editScrollView"){
childConfig.type="scrollView"
}
if(childConfig.type=="editScrollList"){
childConfig.type="scrollList"
}
const childNode = instantiateView(childConfig); const childNode = instantiateView(childConfig);
if (childNode) { if (childNode) {
node.addChild(childNode); node.addChild(childNode);
......
...@@ -8,6 +8,8 @@ import {env} from "./game-warpper/enviroment"; ...@@ -8,6 +8,8 @@ import {env} from "./game-warpper/enviroment";
import {queryParams} from "./web"; import {queryParams} from "./web";
import {httpRequest} from "../2d/net"; import {httpRequest} from "../2d/net";
import {injectProp} from "./utils/utils"; import {injectProp} from "./utils/utils";
import {globalEvent} from "./decorators/events";
import {Event} from "../2d/events/Event";
export function dealPxEnv() { export function dealPxEnv() {
//appID提取 //appID提取
...@@ -51,7 +53,7 @@ export function dealPxEnv() { ...@@ -51,7 +53,7 @@ export function dealPxEnv() {
} }
} }
export function cleanNewUser(){ export function cleanNewUser() {
let key = 'nu_' + env.appID + '_' + env.projectID; let key = 'nu_' + env.appID + '_' + env.projectID;
localStorage.removeItem(key); localStorage.removeItem(key);
} }
...@@ -59,28 +61,18 @@ export function cleanNewUser(){ ...@@ -59,28 +61,18 @@ export function cleanNewUser(){
export function dealPageRemainTime() { export function dealPageRemainTime() {
let startTimer = new Date().getTime(); let startTimer = new Date().getTime();
let endTimer; let endTimer;
//设置隐藏属性和改变可见属性的事件的名称
let visibilityChange;
if (typeof document.hidden !== 'undefined') {
visibilityChange = 'visibilitychange';
} else if (typeof document['msHidden'] !== 'undefined') {
visibilityChange = 'msvisibilitychange';
} else if (typeof document['webkitHidden'] !== 'undefined') {
visibilityChange = 'webkitvisibilitychange';
}
const handleVisibilityChange = (e) => { globalEvent.addEventListener(Event.WINDOW_VISIBILITY_CHANGE, (e) => {
if (document.visibilityState == "visible") { if (e.data.visible) {
startTimer = new Date().getTime(); startTimer = new Date().getTime();
//console.log('starttimer', startTimer) //console.log('starttimer', startTimer)
} } else {
if (document.visibilityState == "hidden") {
endTimer = new Date().getTime(); endTimer = new Date().getTime();
//console.log('endTimer', endTimer); //console.log('endTimer', endTimer);
sendData(); sendData();
} }
}; });
const sendData = () => { const sendData = () => {
const t0 = endTimer - startTimer; const t0 = endTimer - startTimer;
...@@ -91,12 +83,6 @@ export function dealPageRemainTime() { ...@@ -91,12 +83,6 @@ export function dealPageRemainTime() {
}); });
}; };
document.addEventListener(
visibilityChange,
handleVisibilityChange,
false
);
document.body['onbeforeunload'] = () => { document.body['onbeforeunload'] = () => {
endTimer = new Date().getTime(); endTimer = new Date().getTime();
return sendData(); return sendData();
......
/** /**
* Created by rockyl on 2019-12-10. * Created by rockyl on 2019-12-10.
*/ */
import {globalEvent,} from "./decorators/events";
import {Event,} from "../2d/events/Event";
export let queryParams: any = {}; export let queryParams: any = {};
...@@ -50,3 +52,27 @@ function _appendScript(scriptContent, parent) { ...@@ -50,3 +52,27 @@ function _appendScript(scriptContent, parent) {
scriptEl.innerHTML = scriptContent; scriptEl.innerHTML = scriptContent;
parent.appendChild(scriptEl); parent.appendChild(scriptEl);
} }
function windowVisibility() {
//设置隐藏属性和改变可见属性的事件的名称
let visibilityChange;
if (typeof document.hidden !== 'undefined') {
visibilityChange = 'visibilitychange';
} else if (typeof document['msHidden'] !== 'undefined') {
visibilityChange = 'msvisibilitychange';
} else if (typeof document['webkitHidden'] !== 'undefined') {
visibilityChange = 'webkitvisibilitychange';
}
const handleVisibilityChange = (e) => {
globalEvent.dispatchEvent(Event.WINDOW_VISIBILITY_CHANGE, {visible: document.visibilityState == "visible"})
};
document.addEventListener(
visibilityChange,
handleVisibilityChange,
false
);
}
windowVisibility();
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment