Commit 8158cdcc authored by rockyl's avatar rockyl

增加私有自定义事件触发

parent 6d5d91df
......@@ -1168,6 +1168,18 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "frame", {
get: function () {
return {
x: this.x,
y: this.y,
width: this._width,
height: this._height,
};
},
enumerable: true,
configurable: true
});
DisplayObject.prototype.attachVisibility = function () {
};
Object.defineProperty(DisplayObject.prototype, "_tempDisplayObjectParent", {
......@@ -1677,7 +1689,6 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
}
};
AdjustProxy.prototype.adjustLayout = function () {
return;
var that = this._host;
var _a = that.parent, pWidth = _a.width, pHeight = _a.height;
var width = that.width, height = that.height;
......@@ -1962,10 +1973,14 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
}
return target;
}
function traverseViewNode(node, callback) {
function traverseViewNode(node, callback, includeSelf) {
if (includeSelf === void 0) { includeSelf = false; }
if (includeSelf) {
callback(node);
}
for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
var child = _a[_i];
callback(child);
callback(child, node);
if (child.children && child.children.length > 0) {
traverseViewNode(child, callback);
}
......@@ -2982,7 +2997,11 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
EventsProxy.prototype.start = function (eventsConfig) {
this._eventsConfig = eventsConfig;
for (var name in eventsConfig) {
globalEvent.addEventListener(name, this.onCustomEvent, this);
var config = eventsConfig[name];
if (config.custom) {
var target = config.private ? this.host : globalEvent;
target.addEventListener(name, this.onCustomEvent, this);
}
}
this.invokeBehavior('init', this.host);
};
......@@ -3049,6 +3068,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
_this.mouseChildren = true;
_this._instanceType = "Container";
_this.children = [];
_this._transform = _this.transform;
_this.afterConstructor();
return _this;
}
......@@ -3289,7 +3309,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
child.updateTransform();
}
}
if (isUI(this) && this._lastLocalID !== this.transform.localID) {
if (this._transform === this.transform && isUI(this) && this._lastLocalID !== this.transform.localID) {
this._lastLocalID = this.transform.localID;
this.stage.layoutInvalid = true;
}
......@@ -3456,6 +3476,8 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
set: function (value) {
if (this._width !== value) {
this._width = value;
if (this.stage)
this.stage.layoutInvalid = true;
this.dispatchEvent(Event.RESIZE);
}
},
......@@ -3469,6 +3491,8 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
set: function (value) {
if (this._height !== value) {
this._height = value;
if (this.stage)
this.stage.layoutInvalid = true;
this.dispatchEvent(Event.RESIZE);
}
},
......@@ -7999,8 +8023,12 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
else {
cp = new Point();
}
cp.x = (points[o].clientX - points[o].target.offsetLeft + window.pageXOffset) * devicePixelRatio;
cp.y = (points[o].clientY - points[o].target.offsetTop + window.pageYOffset) * devicePixelRatio;
var doc = document.documentElement;
var box = points[o].target.getBoundingClientRect();
var left = box.left + window.pageXOffset - doc.clientLeft;
var top = box.top + window.pageYOffset - doc.clientTop;
cp.x = (points[o].pageX - left) * devicePixelRatio;
cp.y = (points[o].pageY - top) * devicePixelRatio;
sp = s.globalToLocal(cp, DisplayObject._bp);
if (EventDispatcher.getMouseEventCount() > 0) {
if (!s._ml[eLen]) {
......@@ -8286,11 +8314,6 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
}
};
Stage.prototype.afterUpdateTransform = function () {
this.calculateBounds();
if (this.layoutInvalid) {
this.dispatchEvent(Event.LAYOUT_INVALID);
this.layoutInvalid = false;
}
};
Stage.prototype.destroy = function () {
var s = this;
......@@ -19328,6 +19351,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
tslib_1.__extends(Toast, _super);
function Toast(gameStage) {
var _this = _super.call(this) || this;
_this.name = 'toast';
_this._gameStage = gameStage;
_this.mouseEnabled = _this.mouseChildren = false;
_this.horizonCenter = 0;
......@@ -19434,6 +19458,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
_this.addChild(blackLayer);
_this.addChild(_this._popupContainer = new StackContainer());
_this.addChild(_this._toast = new Toast(_this));
blackLayer.name = 'blackLayer';
blackLayer.percentWidth = 100;
blackLayer.percentHeight = 100;
blackLayer.visible = false;
......@@ -19693,7 +19718,43 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
_stage.addEventListener(Event.LAYOUT_INVALID, onLayoutInvalid);
}
function onLayoutInvalid() {
console.log('onLayoutInvalid');
console.time('adjustLayout');
var layoutTree = duplicateLayoutTree(_stage);
console.log(layoutTree);
console.timeEnd('adjustLayout');
}
function duplicateLayoutTree(node) {
var tree = {};
getLayoutTreeOnce(node, tree, true);
return tree;
}
function getLayoutTreeOnce(node, tree, includeSelf) {
if (includeSelf === void 0) { includeSelf = false; }
if (includeSelf) {
tree.name = node.name;
tree.frame = node.frame;
tree.constraint = node.adjustProxy.data;
tree.children = [];
if (node.isUI) {
tree.isUI = true;
}
}
for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
var child = _a[_i];
var layoutNode = {
name: child.name,
frame: child.frame,
constraint: child.adjustProxy.data,
children: [],
};
if (child.isUI) {
layoutNode.isUI = true;
}
tree.children.push(layoutNode);
if (child.children && child.children.length > 0) {
getLayoutTreeOnce(child, layoutNode);
}
}
}
function launch(url, loadingDelegate, onStart) {
......
This diff is collapsed.
{"id":"engine","url":"engine.56879c475b493bdd1b4fa1522bad7ad2a4d454e7.js"}
\ No newline at end of file
{"id":"engine","url":"engine.5afff35dbf1a3f35d5d37785f6235b47b9f6cedd.js"}
\ No newline at end of file
......@@ -63,7 +63,12 @@ class EventsProxy extends HashObject {
start(eventsConfig) {
this._eventsConfig = eventsConfig;
for (let name in eventsConfig) {
globalEvent.addEventListener(name, this.onCustomEvent, this);
let config = eventsConfig[name];
if(config.custom){
let target = config.private ? this.host : globalEvent;
target.addEventListener(name, this.onCustomEvent, this);
}
}
this.invokeBehavior('init', this.host);
......
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