mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 13:16:10 +03:00
Updated Making OpenSeadragon Plugins (markdown)
parent
05b297b052
commit
71537ec4c4
@ -6,3 +6,18 @@ Tips:
|
|||||||
|
|
||||||
* `OpenSeadragon` is the namespace for all OpenSeadragon properties, classes, and methods. Adding a new top level function could be as simple as `OpenSeadragon.myFunc = function() { ... }`.
|
* `OpenSeadragon` is the namespace for all OpenSeadragon properties, classes, and methods. Adding a new top level function could be as simple as `OpenSeadragon.myFunc = function() { ... }`.
|
||||||
* If you want to add methods to any of OpenSeadragon's classes, add it to the class's prototype, such as `OpenSeadragon.Viewer.prototype.myFunc = function() { ... }`.
|
* If you want to add methods to any of OpenSeadragon's classes, add it to the class's prototype, such as `OpenSeadragon.Viewer.prototype.myFunc = function() { ... }`.
|
||||||
|
* Minimize your plugin's footprint: instead of adding a bunch of new methods, just add a single multi-purpose method. That way you're less likely to collide with other plugins, and it'll be easier for developers to keep track of what belongs to your plugin.
|
||||||
|
* Use an "options" object in your method to keep things flexible.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```
|
||||||
|
(function($) {
|
||||||
|
OpenSeadragon.myPlugin = function(options) {
|
||||||
|
options = options || {};
|
||||||
|
if (options.foo) {
|
||||||
|
...
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})(OpenSeadragon);
|
||||||
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user