Event Properties
jCanvas supports a number of event-related properties which make the Event API more powerful and flexible.
The eventX
and eventY
properties
In any event callback, you have access to the layer’s eventX
and eventY
properties. These are the coordinates of the pointer (either mouse or finger) when the event fired.
In the following example, the closer you hover to the circle’s center, the more transparent it will become.
The dx
and dy
properties.
In any drag-related event callback for a draggable layer, you have access to the layer’s dx
and dy
properties. These properties represent the change in the layer’s position when dragging.
That is, the larger the values are, the faster you are dragging the layer. Conversely, the smaller the values, the slower you are dragging. Also note that these values can be positive or negative depending on the direction of the drag.
In the following example, the opacity of the circle is determined by the speed at which you drag it; that is, the circle will become more faded the faster you drag it.
The cursors
property
The cursors
property is used to display a specific cursor when a particular layer event fires.
jCanvas also adds the correct vendor prefix to a select few CSS3 cursors that require a vendor prefix. These cursor values include grab
, grabbing
, zoom-in
, and zoom-out
.
Please note that the cursor always reverts to its previous state when you mouse off the layer.
The intangible
property
The intangible
property essentially allows you to “click through” a layer as
if it didn’t exist. While a layer is intangible, any mouse events attached to it
don’t fire, and any interactions with the layer pass through to layers below.