canvas.on('mousemove', this._handleMouseMove, this);
Roo.select('html').first().on('mouseup', this._handleMouseUp, this);
- if (window.ontouchstart) {
+ if (window.PointerEvent) {
+ canvas.on('pointerdown', this._handleMouseDown, this);
+ canvas.on('pointermove', this._handleMouseMove, this);
+ Roo.select('html').first().on('pointerup', this._handleMouseUp, this);
+ }
+
+ if ('ontouchstart' in window) {
canvas.on('touchstart', this._handleTouchStart, this);
canvas.on('touchmove', this._handleTouchMove, this);
canvas.on('touchend', this._handleTouchEnd, this);
resize: function(){
+ var canvas = this.canvasEl().dom;
+ var ctx = this.canvasElCtx();
+ var img_data = ctx.getImageData(0, 0, canvas.width, canvas.height);
+
+ // setting canvas width will clean img data
+ canvas.width = 0;
+
var style = window.getComputedStyle ?
getComputedStyle(this.el.dom, null) : this.el.dom.currentStyle;
-
+
var padding_left = parseInt(style.paddingLeft) || 0;
var padding_right = parseInt(style.paddingRight) || 0;
- this.canvasEl().dom.width = this.el.dom.clientWidth - padding_left - padding_right;
+ canvas.width = this.el.dom.clientWidth - padding_left - padding_right;
+
+ ctx.putImageData(img_data, 0, 0);
},
_handleMouseDown: function(e)
},
_handleTouchStart: function (e) {
+
e.preventDefault();
if (e.browserEvent.targetTouches.length === 1) {
// var touch = e.browserEvent.changedTouches[0];
e.preventDefault();
// var touch = event.targetTouches[0];
// _this._strokeMoveUpdate(touch);
- this._strokeMoveUpdate(e);
+ this.strokeMoveUpdate(e);
},
_handleTouchEnd: function (e) {