Commit a9b27a76 authored by wjf's avatar wjf

l

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