Commit a9b27a76 authored by wjf's avatar wjf

l

parent 43919fd6
...@@ -22,6 +22,6 @@ ...@@ -22,6 +22,6 @@
"uglifyjs-webpack-plugin": "^2.1.2" "uglifyjs-webpack-plugin": "^2.1.2"
}, },
"keywords": [ "keywords": [
"淘宝小程序,canvas" "淘宝小程序,canvas,webgl"
] ]
} }
\ No newline at end of file
...@@ -313,6 +313,7 @@ export class EventDispatcher extends HashObject { ...@@ -313,6 +313,7 @@ export class EventDispatcher extends HashObject {
let s = this; let s = this;
s.removeAllEventListener(); s.removeAllEventListener();
s.eventTypes = null; s.eventTypes = null;
s.eventTypes1 = null;
} }
} }
......
export class GDispatcher { import { EventDispatcher } from "./EventDispatcher";
/**
* 事件回调池
*/
private static callbackPool: any = {};
/** /**
* 事件作用域池 * 全局事件派发器
*/ */
private static thisObjPool: any = {}; export const GDispatcher: EventDispatcher = new EventDispatcher()
/** //下面这个用习惯了,但是为了统一,还是改吧,engine和fyge里都没改,用着呢有地方
* // export class GDispatcher {
* @param name 事件名 // /**
* @param callback 回调 // * 事件回调池
* @param thisObj 作用域 // */
*/ // private static callbackPool: any = {};
public static addEvent(name: string, callback, thisObj?: any): void {
if (!this.callbackPool[name]) {
this.callbackPool[name] = [];
this.thisObjPool[name] = [];
}
const index: number = this.callbackPool[name].indexOf(callback); // /**
if (index != -1) { // * 事件作用域池
this.callbackPool[name][index] = callback; // */
this.thisObjPool[name][index] = thisObj; // private static thisObjPool: any = {};
} else {
this.callbackPool[name].push(callback);
this.thisObjPool[name].push(thisObj);
}
}
/** // /**
* // *
* @param name 事件名 // * @param name 事件名
* @param callback 回调 // * @param callback 回调
* @param thisObj 作用域 // * @param thisObj 作用域
*/ // */
public static removeEvent(name: string, callback, thisObj?: any): void { // public static addEvent(name: string, callback, thisObj?: any): void {
if (this.callbackPool[name]) { // if (!this.callbackPool[name]) {
var len = this.callbackPool[name].length; // this.callbackPool[name] = [];
for (let i = len - 1; i >= 0; i--) { // this.thisObjPool[name] = [];
if (this.callbackPool[name][i] === callback && this.thisObjPool[name][i] == thisObj) { // }
this.callbackPool[name].splice(i, 1);
this.thisObjPool[name].splice(i, 1);
}
}
// const index: number = this.callbackPool[name].indexOf(callback);
// if (index != -1) {
// this.callbackPool[name].splice(index, 1);
// this.thisObjPool[name].splice(index, 1);
// }
}
}
/** // const index: number = this.callbackPool[name].indexOf(callback);
* 派发事件 // if (index != -1) {
* @param name 事件名 // this.callbackPool[name][index] = callback;
* @param args 任意参数 // this.thisObjPool[name][index] = thisObj;
*/ // } else {
public static dispatchEvent(name: string, ...args): void { // this.callbackPool[name].push(callback);
const callbacks: Function[] = this.callbackPool[name]; // this.thisObjPool[name].push(thisObj);
const thisObjs: any = this.thisObjPool[name]; // }
if (callbacks) { // }
let i = 0;
const len: number = callbacks.length; // /**
for (i; i < len; i++) { // *
callbacks[i].apply(thisObjs[i], args); // * @param name 事件名
} // * @param callback 回调
} // * @param thisObj 作用域
} // */
} // public static removeEvent(name: string, callback, thisObj?: any): void {
\ No newline at end of file // if (this.callbackPool[name]) {
// var len = this.callbackPool[name].length;
// for (let i = len - 1; i >= 0; i--) {
// if (this.callbackPool[name][i] === callback && this.thisObjPool[name][i] == thisObj) {
// this.callbackPool[name].splice(i, 1);
// this.thisObjPool[name].splice(i, 1);
// }
// }
// // const index: number = this.callbackPool[name].indexOf(callback);
// // if (index != -1) {
// // this.callbackPool[name].splice(index, 1);
// // this.thisObjPool[name].splice(index, 1);
// // }
// }
// }
// /**
// * 派发事件
// * @param name 事件名
// * @param args 任意参数
// */
// public static dispatchEvent(name: string, ...args): void {
// const callbacks: Function[] = this.callbackPool[name];
// const thisObjs: any = this.thisObjPool[name];
// if (callbacks) {
// let i = 0;
// const len: number = callbacks.length;
// for (i; i < len; i++) {
// callbacks[i].apply(thisObjs[i], args);
// }
// }
// }
// }
\ No newline at end of file
...@@ -582,7 +582,7 @@ export class TextField extends Sprite { ...@@ -582,7 +582,7 @@ export class TextField extends Sprite {
let canHeight = maxH + padding * 2; let canHeight = maxH + padding * 2;
can.width = canWidth can.width = canWidth
can.height = canHeight can.height = canHeight
ctx.clearRect(0, 0, can.width, can.height); ctx.clearRect(0, 0, can.width, can.height);//安卓貌似无效,文案重叠了再处理,或者等修复了尺寸问题就好了
if (s.border) { if (s.border) {
ctx.beginPath(); ctx.beginPath();
ctx.strokeStyle = "#000"; ctx.strokeStyle = "#000";
......
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