mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-02 02:54:43 +00:00
"mousemove" event listener on document is now only attached after "mousedown" on canvas. This avoids unnecessary work when moving mouse outside of canvas (especially with multiple canvas instances on a page).
This commit is contained in:
parent
2deedd02dd
commit
09fd6210b1
4 changed files with 13 additions and 7 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/*! Fabric.js Copyright 2008-2011, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */
|
||||
|
||||
var fabric = fabric || { version: "0.5.3" };
|
||||
var fabric = fabric || { version: "0.5.4" };
|
||||
|
||||
if (typeof exports != 'undefined') {
|
||||
exports.fabric = fabric;
|
||||
|
|
|
|||
9
dist/all.js
vendored
9
dist/all.js
vendored
|
|
@ -1,6 +1,6 @@
|
|||
/*! Fabric.js Copyright 2008-2011, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */
|
||||
|
||||
var fabric = fabric || { version: "0.5.3" };
|
||||
var fabric = fabric || { version: "0.5.4" };
|
||||
|
||||
if (typeof exports != 'undefined') {
|
||||
exports.fabric = fabric;
|
||||
|
|
@ -4588,22 +4588,25 @@ fabric.util.string = {
|
|||
* See configuration documentation for more details.
|
||||
*/
|
||||
_initEvents: function () {
|
||||
|
||||
var _this = this;
|
||||
|
||||
this._onMouseDown = function (e) {
|
||||
_this.__onMouseDown(e);
|
||||
addListener(fabric.document, 'mouseup', _this._onMouseUp);
|
||||
addListener(fabric.document, 'mousemove', _this._onMouseMove);
|
||||
removeListener(_this.upperCanvasEl, 'mousemove', _this._onMouseMove);
|
||||
};
|
||||
this._onMouseUp = function (e) {
|
||||
_this.__onMouseUp(e);
|
||||
removeListener(fabric.document, 'mouseup', _this._onMouseUp);
|
||||
removeListener(fabric.document, 'mousemove', _this._onMouseMove);
|
||||
addListener(_this.upperCanvasEl, 'mousemove', _this._onMouseMove);
|
||||
};
|
||||
this._onMouseMove = function (e) { _this.__onMouseMove(e); };
|
||||
this._onResize = function (e) { _this.calcOffset() };
|
||||
|
||||
addListener(this.upperCanvasEl, 'mousedown', this._onMouseDown);
|
||||
addListener(fabric.document, 'mousemove', this._onMouseMove);
|
||||
addListener(this.upperCanvasEl, 'mousemove', this._onMouseMove);
|
||||
addListener(fabric.window, 'resize', this._onResize);
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "fabric",
|
||||
"description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.",
|
||||
"version": "0.5.3",
|
||||
"version": "0.5.4",
|
||||
"author": "Juriy Zaytsev <kangax@gmail.com>",
|
||||
"keywords": ["canvas", "graphic", "graphics", "SVG", "node-canvas", "parser", "HTML5", "object model"],
|
||||
"repository": "git://github.com/kangax/fabric.js",
|
||||
|
|
|
|||
|
|
@ -360,22 +360,25 @@
|
|||
* See configuration documentation for more details.
|
||||
*/
|
||||
_initEvents: function () {
|
||||
|
||||
var _this = this;
|
||||
|
||||
this._onMouseDown = function (e) {
|
||||
_this.__onMouseDown(e);
|
||||
addListener(fabric.document, 'mouseup', _this._onMouseUp);
|
||||
addListener(fabric.document, 'mousemove', _this._onMouseMove);
|
||||
removeListener(_this.upperCanvasEl, 'mousemove', _this._onMouseMove);
|
||||
};
|
||||
this._onMouseUp = function (e) {
|
||||
_this.__onMouseUp(e);
|
||||
removeListener(fabric.document, 'mouseup', _this._onMouseUp);
|
||||
removeListener(fabric.document, 'mousemove', _this._onMouseMove);
|
||||
addListener(_this.upperCanvasEl, 'mousemove', _this._onMouseMove);
|
||||
};
|
||||
this._onMouseMove = function (e) { _this.__onMouseMove(e); };
|
||||
this._onResize = function (e) { _this.calcOffset() };
|
||||
|
||||
addListener(this.upperCanvasEl, 'mousedown', this._onMouseDown);
|
||||
addListener(fabric.document, 'mousemove', this._onMouseMove);
|
||||
addListener(this.upperCanvasEl, 'mousemove', this._onMouseMove);
|
||||
addListener(fabric.window, 'resize', this._onResize);
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue