dist/jcanvas.js
function _createEvent(eventName) {

	jCanvas.events[eventName] = function ($canvas, data) {
		var helperEventName, touchEventName, eventCache;

		// Retrieve canvas's event cache
		eventCache = data.event;

		// Both mouseover/mouseout events will be managed by a single mousemove event
		helperEventName = (eventName === 'mouseover' || eventName === 'mouseout') ? 'mousemove' : eventName;
		touchEventName = _getTouchEventName(helperEventName);

		function eventCallback(event) {
			// Cache current mouse position and redraw layers
			eventCache.x = event.offsetX;
			eventCache.y = event.offsetY;
			eventCache.type = helperEventName;
			eventCache.event = event;
			// Redraw layers on every trigger of the event; don't redraw if at
			// least one layer is draggable and there are no layers with
			// explicit mouseover/mouseout/mousemove events
			if (event.type !== 'mousemove' || data.redrawOnMousemove || data.drag.dragging) {
				$canvas.drawLayers({
					resetFire: true
				});
			}
			// Prevent default event behavior
			event.preventDefault();
		}

		// Ensure the event is not bound more than once
		if (!data.events[helperEventName]) {
			// Bind one canvas event which handles all layer events of that type
			if (touchEventName !== helperEventName) {
				$canvas.bind(helperEventName + '.jCanvas ' + touchEventName + '.jCanvas', eventCallback);
			} else {
				$canvas.bind(helperEventName + '.jCanvas', eventCallback);
			}
			// Prevent this event from being bound twice
			data.events[helperEventName] = true;
		}
	};
}
function _createEvent(eventName) {

	jCanvas.events[eventName] = function ($canvas, data) {
		var helperEventName, touchEventName, eventCache;

		// Retrieve canvas's event cache
		eventCache = data.event;

		// Both mouseover/mouseout events will be managed by a single mousemove event
		helperEventName = (eventName === 'mouseover' || eventName === 'mouseout') ? 'mousemove' : eventName;
		touchEventName = _getTouchEventName(helperEventName);

		function eventCallback(event) {
			// Cache current mouse position and redraw layers
			eventCache.x = event.offsetX;
			eventCache.y = event.offsetY;
			eventCache.type = helperEventName;
			eventCache.event = event;
			// Redraw layers on every trigger of the event; don't redraw if at
			// least one layer is draggable and there are no layers with
			// explicit mouseover/mouseout/mousemove events
			if (event.type !== 'mousemove' || data.redrawOnMousemove || data.drag.dragging) {
				$canvas.drawLayers({
					resetFire: true
				});
			}
			// Prevent default event behavior
			event.preventDefault();
		}

		// Ensure the event is not bound more than once
		if (!data.events[helperEventName]) {
			// Bind one canvas event which handles all layer events of that type
			if (touchEventName !== helperEventName) {
				$canvas.bind(helperEventName + '.jCanvas ' + touchEventName + '.jCanvas', eventCallback);
			} else {
				$canvas.bind(helperEventName + '.jCanvas', eventCallback);
			}
			// Prevent this event from being bound twice
			data.events[helperEventName] = true;
		}
	};
}
function _createEvent ( eventName ) { jCanvas . events [ eventName ] = function ( $canvas , data ) { var helperEventName , touchEventName , eventCache ; // Retrieve canvas's event cache eventCache = data . event ; // Both mouseover/mouseout events will be managed by a single mousemove event helperEventName = ( eventName === 'mouseover' || eventName === 'mouseout' ) ? 'mousemove' : eventName ; touchEventName = _getTouchEventName ( helperEventName ) ; function eventCallback ( event ) { // Cache current mouse position and redraw layers eventCache . x = event . offsetX ; eventCache . y = event . offsetY ; eventCache . type = helperEventName ; eventCache . event = event ; // Redraw layers on every trigger of the event; don't redraw if at // least one layer is draggable and there are no layers with // explicit mouseover/mouseout/mousemove events if ( event . type !== 'mousemove' || data . redrawOnMousemove || data . drag . dragging ) { $canvas . drawLayers ( { resetFire : true } ) ; } // Prevent default event behavior event . preventDefault ( ) ; } // Ensure the event is not bound more than once if ( ! data . events [ helperEventName ] ) { // Bind one canvas event which handles all layer events of that type if ( touchEventName !== helperEventName ) { $canvas . bind ( helperEventName + '.jCanvas ' + touchEventName + '.jCanvas' , eventCallback ) ; } else { $canvas . bind ( helperEventName + '.jCanvas' , eventCallback ) ; } // Prevent this event from being bound twice data . events [ helperEventName ] = true ; } } ; }
Bind event to jCanvas layer using standard jQuery events
Bind event to jCanvas layer using standard jQuery events