Commit e0aba4ed authored by rockyl's avatar rockyl

解决滚动条不跟手的问题

解决舞台适配问题
优化过程执行,如果子过程只有一个就跳过
parent e3c51ee3
This diff is collapsed.
This diff is collapsed.
import Container from "../display/Container";
import Graphics from "../graphics/Graphics";
import { MouseEvent } from "../events/MouseEvent";
import { Event } from "../events/Event";
import {MouseEvent} from "../events/MouseEvent";
import {Event} from "../events/Event";
// import Tween from "../../tweenSimple/Tween";
......@@ -62,7 +62,7 @@ export class ScrollContainer extends Container {
* 最小鼠标滑动距离
* @type {number}
*/
private minDis: number = 2;
private minDis: number = 0;
/**
* 遮罩对象
* @property maskObj
......@@ -309,8 +309,8 @@ export class ScrollContainer extends Container {
}
s.speed = 0;
s.isMouseDownState = 1;
}
else if (e.type == MouseEvent.MOUSE_MOVE) {
} else if (e.type == MouseEvent.MOUSE_MOVE) {
if (s.isMouseDownState == 0) return;
if (s.isMouseDownState == 1) {
s.dispatchEvent(Event.ON_SCROLL_START);
}
......
......@@ -78,7 +78,12 @@ export class Process {
}
} else {
const scriptResult = await this._executeMetaScript('', args, metaConfig);
const subProcessResult = await this._executeSubProcess(scriptResult.type, scriptResult.payload);
let subProcessResult;
if (this._meta.sub && Object.keys(this._meta.sub).length > 1) {
subProcessResult = await this._executeSubProcess(scriptResult.type, scriptResult.payload);
} else {
subProcessResult = scriptResult;
}
result = await this._executeNextProcess(subProcessResult.type, subProcessResult.payload);
}
......
......@@ -5,6 +5,7 @@
*/
import {Event} from "../../2d/events";
import {Stage} from "../../2d/display";
/**
* 应用自适应
......@@ -94,7 +95,14 @@ class AdjustProxy {
adjustLayout() {
const that = this._host;
const {width: pWidth, height: pHeight} = that.parent;
let pWidth, pHeight;
//if(that.parent instanceof Stage){
// pWidth = that.parent.desWidth;
// pHeight = that.parent.desHeight;
//}else{
pWidth = that.parent.width;
pHeight = that.parent.height;
//}
const {width, height} = that;
const {percentWidth, percentHeight, left, top, right, bottom, horizonCenter, verticalCenter} = this.data;
......
......@@ -35,11 +35,13 @@ export class GameStage extends Container {
this.name = 'game-stage';
stage.width = stage.viewRect.width;
stage.height = stage.viewRect.height;
this._stage = stage;
this._dataCenter = dataCenter;
this['percentWidth'] = 100;
this['percentHeight'] = 100;
this.percentWidth = 100;
this.percentHeight = 100;
this.mouseEnabled = false;
let blackLayer = this._blackLayer = new Rect();
......@@ -49,8 +51,8 @@ export class GameStage extends Container {
this.addChild(this._popupContainer = new StackContainer(false));
this.addChild(this._toast = new Toast(this));
blackLayer['percentWidth'] = 100;
blackLayer['percentHeight'] = 100;
blackLayer.percentWidth = 100;
blackLayer.percentHeight = 100;
blackLayer.visible = false;
blackLayer.fillColor = 0;
blackLayer.alpha = 0.7;
......
......@@ -16,8 +16,8 @@ export class StackContainer extends Container {
this._mutex = mutex;
this['percentWidth'] = 100;
this['percentHeight'] = 100;
this.percentWidth = 100;
this.percentHeight = 100;
this.mouseEnabled = false;
}
......
......@@ -7,6 +7,7 @@ import {RENDERER_TYPE, StageScaleMode} from "..";
import {GameStage} from "./game-warpper";
import {setGlobalContext} from "./behavior-runtime";
import {globalLoader} from "../2d/loader/Loader";
import {Event} from "../2d/events/Event";
export let gameStage;
......@@ -40,13 +41,13 @@ export function launchWithConfig(config, onAssetsProgress, onAssetsComplete) {
);
Stage.flushAll();
gameStage = new GameStage(stage);
setGlobalContext({
gameStage
});
stage.addChild(gameStage);
stage.addEventListener(Event.ON_INIT_STAGE, ()=>{
gameStage = new GameStage(stage);
setGlobalContext({
gameStage
});
stage.addChild(gameStage);
setTimeout(() => {
gameStage.launch(config, onAssetsProgress, onAssetsComplete);
});
......
......@@ -204,3 +204,17 @@ export function findVariable(name: string, ...contexts) {
}
return result;
}
let el;
export function htmlToPureText(htmlText) {
if (!el) {
el = document.createElement('div');
}
el.innerHTML = htmlText;
document.body.append(el);
let pureText = el.innerText;
document.body.removeChild(el);
return pureText;
}
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