Custom triggers
Paver exposes several public functions that developers can manipulate with in order to trigger desired behavior without interacting with the plugin. In order to maintain direct chainability with other jQuery methods, I have chosen not to implement public methods that can be called by chaining, i.e. $(selector).paver().destroy()
. However, I have provisioned three distinct ways where you can access public functions in Paver. args
represent accepted arguments for the respective public function(s):
- By accessing the
plugin_data
object of the Paver instances:$(selector).data('plugin_paver').customTrigger([args]);
- By passing the name of custom trigger as a string into the
.paver()
method:$(selector).paver('customTrigger'[, args]);
- By triggering a namespaced custom event at the Paver instance:
$(selector).trigger('customTrigger.paver');
Note that all custom triggers will only be triggered after the Paver is successfully intialized and ready to use, i.e. when the ready.paver
event is fired. To avoid user confusion/frustration when accessing public functions in the event that Paver is not yet ready, I strongly recommend also binding events after ready.paver
has been fired, i.e.:
// Initialize paver
$(paverSelector).paver();
// Allow user to destroy instance only after when ready
$(paverSelector).on('ready.paver', funtion() {
$('button').prop('disable', false);
});
$('button').on('click', function() {
$(paverSelector).paver('destroy');
// or: $(this).data('plugin_paver').destroy();
// or: $(this).trigger('destroy.paver');
});
Function name | Arguments | Description |
destroy | None | Destroys the Paver instance, and reinserts the original DOM node in its place. Will emit the |
---|---|---|
pan | Object
|
Pans the panorama in the Paver instance. Only a single argument is accepted, and it has to be in the form of an object. When no arguments are passed, triggering |
recompute | None | Triggers recomputing and binding of events to Paver instances that satisfy the selector. Will emit the |
Custom events
There are two kinds of custom events emitted: global custom events, or scoped custom events (triggered by each Paver instance). All events are namespaced, i.e. eventName.paver
. The purpose behind creating custom events is to enable developers to (1) check if Paver has been enabled, (2) verify that gyroscopic data is available, (3) keep track of the progress of Paver initialization or the internal calculation events triggered.
Global
Global events are triggered on the document
object, i.e:
$(document).on('enabled.paver', function() {
// Paver is enabled!
});
Event Name | Conditional | Description |
hasGyroscopeData | Yes. See also: hasNoGyroscopeData |
This event and The following gyroscopic data is passed to the event handler as an object, when the JavaScript deferred object is resolved:
The gyroscopic data object can be accessed using:
|
---|---|---|
hasNoGyroScopeData | Yes. See also: hasGyroscopeData |
This event and
|
enabled | Yes. See also: disabled |
This event and
|
disabled | Yes. See also: enabled |
This event and
|
Scoped (Individual)
Scoped (individual) events are triggered on the selector for each Paver instance, i.e:
$('div.paver').on('init.paver', function() {
// Paver is initialized
});
Note that many scoped events are mutually-exclusive, such that only one in a pair will be triggered. They are labelled as "conditional" in the table below:
Event Name | Conditional | Description |
imageLoadDone | Yes. See also imageLoadFail |
This event and |
---|---|---|
imageLoadFail | Yes. See also imageLoadDone |
This event and |
init | No | Fired when Paver is initialized, i.e. when DOM replacements are performed. This happens after:
|
ready | No | Fired when original panorama image is hidden and DOM replacements have been performed. At this point the plugin will proceed to compute dimensions and conditionally bind/unbind events. |
computeEnd | No | Fired when panorama dimensions have been computed, and the dimensions of the dummy panorama wrapper have been set. |
eventsBound | Yes. See also: eventsUnbound |
This event and |
eventsUnbound | Yes. See also: eventsBound |
This event and |
initialPanStart | Yes. See also: panStart |
This event and |
panStart | Yes. See also: initialPanStart |
This event and
|
initialPanEnd | Yes. See also: panEnd |
This event and |
panEnd | Yes. See also: initialPanEnd |
This event and |
recomputeStart | No | Fired when a window resize event is detected, or a |
destroyed | No | Fired when the Paver instance has been destroyed—this occurs after the reinsertion of the original DOM node, removal of all event handlers, resetting of Paver-related classes and resetting of the initialization status of the Paver instance of element(s) of interest. |