Expose cursor style for hovered objects through fabric.Canvas#HOVER_CURSOR for customization purposes.

This commit is contained in:
kangax 2011-07-02 01:33:43 -04:00
parent 1bed43e3c4
commit 0e3831ed6f
4 changed files with 25 additions and 4 deletions

View file

@ -37,6 +37,11 @@
<h3>No object boundaries + opacity on move</h3>
<canvas id="c10" width="200" height="200"></canvas>
</div>
<div class="block">
<h3>Custom cursor on object hover</h3>
<canvas id="c11" width="200" height="200"></canvas>
</div>
<div class="block">
<h3>Unselectable canvas</h3>
@ -118,6 +123,10 @@
}
});
var canvas11 = new fabric.Canvas('c11');
canvas11.add(new fabric.Circle({ radius: 30, fill: '#f55', top: 100, left: 100 }));
canvas11.HOVER_CURSOR = 'pointer';
var canvas4 = new fabric.Canvas('c4');
canvas4.add(new fabric.Circle({ radius: 30, fill: '#f55', top: 100, left: 100 }));
canvas4.add(new fabric.Rect({ left: 50, top: 50, fill: 'green', width: 30, height: 30 }));

10
dist/all.js vendored
View file

@ -1,6 +1,6 @@
/*! Fabric.js Copyright 2008-2011, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */
var fabric = fabric || { version: "0.3.1" };
var fabric = fabric || { version: "0.3.2" };
/**
* Wrapper around `console.log` (when available)
@ -4089,6 +4089,12 @@ fabric.util.animate = animate;
*/
CONTAINER_CLASS: 'canvas-container',
/**
* @constant
* @type String
*/
HOVER_CURSOR: 'move',
/**
* Callback; invoked right before object is about to be scaled/rotated
* @method onBeforeScaleRotate
@ -4860,7 +4866,7 @@ fabric.util.animate = animate;
&& target._findTargetCorner(e, this._offset);
if (!corner) {
s.cursor = 'move';
s.cursor = this.HOVER_CURSOR;
}
else {
if (corner in cursorMap) {

View file

@ -1,6 +1,6 @@
/*! Fabric.js Copyright 2008-2011, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */
var fabric = fabric || { version: "0.3.1" };
var fabric = fabric || { version: "0.3.2" };
/**
* Wrapper around `console.log` (when available)

View file

@ -215,6 +215,12 @@
*/
CONTAINER_CLASS: 'canvas-container',
/**
* @constant
* @type String
*/
HOVER_CURSOR: 'move',
/**
* Callback; invoked right before object is about to be scaled/rotated
* @method onBeforeScaleRotate
@ -1022,7 +1028,7 @@
&& target._findTargetCorner(e, this._offset);
if (!corner) {
s.cursor = 'move';
s.cursor = this.HOVER_CURSOR;
}
else {
if (corner in cursorMap) {