Commit 7ad67d40 authored by rockyl's avatar rockyl

修复store实例化的问题

parent 0c12aa3e
...@@ -5638,6 +5638,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate: ...@@ -5638,6 +5638,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
this._localBoundsSelf.y = -height * this.anchorTexture.y; this._localBoundsSelf.y = -height * this.anchorTexture.y;
this._localBoundsSelf.width = width; this._localBoundsSelf.width = width;
this._localBoundsSelf.height = height; this._localBoundsSelf.height = height;
this.dispatchEvent(Event.COMPLETE);
this.dispatchEvent(Event.RESIZE); this.dispatchEvent(Event.RESIZE);
}; };
Sprite.prototype._onAnchorUpdate = function () { Sprite.prototype._onAnchorUpdate = function () {
...@@ -5859,7 +5860,6 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate: ...@@ -5859,7 +5860,6 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
}; };
return Sprite; return Sprite;
}(Container)); }(Container));
//# sourceMappingURL=Sprite.js.map
var BatchDrawCall = (function () { var BatchDrawCall = (function () {
function BatchDrawCall() { function BatchDrawCall() {
...@@ -8147,7 +8147,6 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate: ...@@ -8147,7 +8147,6 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
var rootDiv = s.rootDiv; var rootDiv = s.rootDiv;
var doc = document.documentElement; var doc = document.documentElement;
var box = rootDiv.getBoundingClientRect(); var box = rootDiv.getBoundingClientRect();
console.log(box.y);
var left = box.left + window.pageXOffset - doc.clientLeft; var left = box.left + window.pageXOffset - doc.clientLeft;
var top = box.top + window.pageYOffset - doc.clientTop; var top = box.top + window.pageYOffset - doc.clientTop;
cp.x = (points[o].pageX - left) * devicePixelRatio; cp.x = (points[o].pageX - left) * devicePixelRatio;
...@@ -8454,6 +8453,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate: ...@@ -8454,6 +8453,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
Stage.allUpdateObjList = []; Stage.allUpdateObjList = [];
return Stage; return Stage;
}(Container)); }(Container));
//# sourceMappingURL=Stage.js.map
var GraphicsData = (function (_super) { var GraphicsData = (function (_super) {
tslib_1.__extends(GraphicsData, _super); tslib_1.__extends(GraphicsData, _super);
...@@ -20198,10 +20198,10 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate: ...@@ -20198,10 +20198,10 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
function createStore(exp, computed) { function createStore(exp, computed) {
var store = safeEval(exp) || {}; var store = safeEval(exp) || {};
for (var _i = 0, computed_1 = computed; _i < computed_1.length; _i++) { for (var _i = 0, computed_1 = computed; _i < computed_1.length; _i++) {
var item = computed_1[_i]; var _a = computed_1[_i], name = _a.name, script = _a.script;
var getterCode = "return function(){\n\t\t\t" + item.script + "\n\t\t}";
if (name && !store.hasOwnProperty(name)) { if (name && !store.hasOwnProperty(name)) {
Object.defineProperty(store, item.name, { var getterCode = "return function(){\n\t\t\t" + script + "\n\t\t}";
Object.defineProperty(store, name, {
get: safeEval(getterCode), get: safeEval(getterCode),
}); });
} }
......
This diff is collapsed.
...@@ -158,6 +158,7 @@ export default class Sprite extends Container { ...@@ -158,6 +158,7 @@ export default class Sprite extends Container {
this._localBoundsSelf.width = width; this._localBoundsSelf.width = width;
this._localBoundsSelf.height = height; this._localBoundsSelf.height = height;
this.dispatchEvent(Event.COMPLETE);
this.dispatchEvent(Event.RESIZE); this.dispatchEvent(Event.RESIZE);
} }
......
...@@ -35,7 +35,7 @@ export interface IZri ...@@ -35,7 +35,7 @@ export interface IZri
createWatcher(target:any, exp:string, scope:any, callback:WatcherCallback):IWatcher; createWatcher(target:any, exp:string, scope:any, callback:WatcherCallback):IWatcher;
/** /**
* 解析表达式成为命令数据 * 解析表达式成为命令数据
* @param key 属性名,合法的属性名应以a-或a_开头,以:或$分隔主命令和子命令 * @param key 属性名,合法的属性名应以z-或z_开头,以:或$分隔主命令和子命令
* @param value 属性值,如果属性名合法则会被用来作为表达式的字符串 * @param value 属性值,如果属性名合法则会被用来作为表达式的字符串
* @return {CommandData|null} 命令数据,如果不是命令则返回null * @return {CommandData|null} 命令数据,如果不是命令则返回null
*/ */
......
...@@ -49,7 +49,7 @@ export class Zri implements IZri ...@@ -49,7 +49,7 @@ export class Zri implements IZri
/** /**
* 解析表达式成为命令数据 * 解析表达式成为命令数据
* @param key 属性名,合法的属性名应以a-或a_开头,以:或$分隔主命令和子命令 * @param key 属性名,合法的属性名应以z-或z_开头,以:或$分隔主命令和子命令
* @param value 属性值,如果属性名合法则会被用来作为表达式的字符串 * @param value 属性值,如果属性名合法则会被用来作为表达式的字符串
* @param cmdRegExp 可选,如果不传则使用默认的命令正则表达式解析命令 * @param cmdRegExp 可选,如果不传则使用默认的命令正则表达式解析命令
* @return {CommandData|null} 命令数据,如果不是命令则返回null * @return {CommandData|null} 命令数据,如果不是命令则返回null
......
...@@ -27,12 +27,12 @@ export function bind(store: any, view: Container, options?: ZriOptions): IZri { ...@@ -27,12 +27,12 @@ export function bind(store: any, view: Container, options?: ZriOptions): IZri {
*/ */
export function createStore(exp, computed) { export function createStore(exp, computed) {
let store = safeEval(exp) || {}; let store = safeEval(exp) || {};
for (let item of computed) { for (let {name, script} of computed) {
let getterCode = `return function(){
${item.script}
}`;
if (name && !store.hasOwnProperty(name)) { if (name && !store.hasOwnProperty(name)) {
Object.defineProperty(store, item.name, { let getterCode = `return function(){
${script}
}`;
Object.defineProperty(store, name, {
get: safeEval(getterCode), get: safeEval(getterCode),
}) })
} }
......
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