Creats holder for events. Accessible via Viewer.events.
Methods
-
Remove a callback function from a specific CGView event. If no callback is provided, then all callbacks for the event will be removed. Namespaced events can and should be used to avoid unintentionally removing callbacks attached by other plugins. Accessible via Viewer.off().
// Remove all callbacks attached to the 'drag-start' event. // This includes any namespaced events. cgv.off('zoom-start'); // Remove all callbacks attached to the 'drag-start' event namespaced to 'my_plugin' cgv.off('zoom-start.my_plugin'); // Remove all callbacks attached to any events namespaced to 'my_plugin' cgv.off('.my_plugin');Name Type Description eventString Name of event. Events can be namespaced.
callbackfunction Specfic function to remove
-
Attach a callback function to a specific CGView event. Accessible via Viewer.on().
cgv = new CGView.Viewer('#my-viewer'); cgv.on('zoom-start', function() { console.log('Zooming has begun!') }; // The event can be namespaced for easier removal later cgv.on('zoom-start.my_plugin', function() { console.log('Zooming has begun!') };Name Type Description eventString Name of event. Events can be namespaced.
callbackfunction Function to call when event is triggered
-
Trigger a callback function for a specific event. Accessible via Viewer.trigger().
// Triggers all callback functions associated with zoom-start cgv.trigger('zoom-start'); // Triggers can also be namespaced cgv.trigger('zoom-start.my_plugin');Name Type Description eventString Name of event. Events can be namespaced.
objectObject Object to be passed back to 'on'.