dist/jcanvas.js
function _addLayerEvents($canvas, data, layer) {
	var eventName;
	// Determine which jCanvas events need to be bound to this layer
	for (eventName in jCanvas.events) {
		if (Object.prototype.hasOwnProperty.call(jCanvas.events, eventName)) {
			// If layer has callback function to complement it
			if (layer[eventName] || (layer.cursors && layer.cursors[eventName])) {
				// Bind event to layer
				_addExplicitLayerEvent($canvas, data, layer, eventName);
			}
		}
	}
	if (!data.events.mouseout) {
		$canvas.bind('mouseout.jCanvas', function () {
			// Retrieve the layer whose drag event was canceled
			var layer = data.drag.layer, l;
			// If cursor mouses out of canvas while dragging
			if (layer) {
				// Cancel drag
				data.drag = {};
				_triggerLayerEvent($canvas, data, layer, 'dragcancel');
			}
			// Loop through all layers
			for (l = 0; l < data.layers.length; l += 1) {
				layer = data.layers[l];
				// If layer thinks it's still being moused over
				if (layer._hovered) {
					// Trigger mouseout on layer
					$canvas.triggerLayerEvent(data.layers[l], 'mouseout');
				}
			}
			// Redraw layers
			$canvas.drawLayers();
		});
		// Indicate that an event handler has been bound
		data.events.mouseout = true;
	}
}
function _addLayerEvents($canvas, data, layer) {
	var eventName;
	// Determine which jCanvas events need to be bound to this layer
	for (eventName in jCanvas.events) {
		if (Object.prototype.hasOwnProperty.call(jCanvas.events, eventName)) {
			// If layer has callback function to complement it
			if (layer[eventName] || (layer.cursors && layer.cursors[eventName])) {
				// Bind event to layer
				_addExplicitLayerEvent($canvas, data, layer, eventName);
			}
		}
	}
	if (!data.events.mouseout) {
		$canvas.bind('mouseout.jCanvas', function () {
			// Retrieve the layer whose drag event was canceled
			var layer = data.drag.layer, l;
			// If cursor mouses out of canvas while dragging
			if (layer) {
				// Cancel drag
				data.drag = {};
				_triggerLayerEvent($canvas, data, layer, 'dragcancel');
			}
			// Loop through all layers
			for (l = 0; l < data.layers.length; l += 1) {
				layer = data.layers[l];
				// If layer thinks it's still being moused over
				if (layer._hovered) {
					// Trigger mouseout on layer
					$canvas.triggerLayerEvent(data.layers[l], 'mouseout');
				}
			}
			// Redraw layers
			$canvas.drawLayers();
		});
		// Indicate that an event handler has been bound
		data.events.mouseout = true;
	}
}
function _addLayerEvents ( $canvas , data , layer ) { var eventName ; // Determine which jCanvas events need to be bound to this layer for ( eventName in jCanvas . events ) { if ( Object . prototype . hasOwnProperty . call ( jCanvas . events , eventName ) ) { // If layer has callback function to complement it if ( layer [ eventName ] || ( layer . cursors && layer . cursors [ eventName ] ) ) { // Bind event to layer _addExplicitLayerEvent ( $canvas , data , layer , eventName ) ; } } } if ( ! data . events . mouseout ) { $canvas . bind ( 'mouseout.jCanvas' , function ( ) { // Retrieve the layer whose drag event was canceled var layer = data . drag . layer , l ; // If cursor mouses out of canvas while dragging if ( layer ) { // Cancel drag data . drag = { } ; _triggerLayerEvent ( $canvas , data , layer , 'dragcancel' ) ; } // Loop through all layers for ( l = 0 ; l < data . layers . length ; l += 1 ) { layer = data . layers [ l ] ; // If layer thinks it's still being moused over if ( layer . _hovered ) { // Trigger mouseout on layer $canvas . triggerLayerEvent ( data . layers [ l ] , 'mouseout' ) ; } } // Redraw layers $canvas . drawLayers ( ) ; } ) ; // Indicate that an event handler has been bound data . events . mouseout = true ; } }
Initialize all of a layer's associated jCanvas events
Initialize all of a layer s associated jCanvas events