From 71537ec4c4cd1cd5338b772f6d7a2a6f64bfe7b1 Mon Sep 17 00:00:00 2001 From: iangilman Date: Wed, 21 Aug 2013 09:49:39 -0700 Subject: [PATCH] Updated Making OpenSeadragon Plugins (markdown) --- Making-OpenSeadragon-Plugins.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Making-OpenSeadragon-Plugins.md b/Making-OpenSeadragon-Plugins.md index bf51dc0..1e809d8 100644 --- a/Making-OpenSeadragon-Plugins.md +++ b/Making-OpenSeadragon-Plugins.md @@ -5,4 +5,19 @@ Once you have created your plugin, link to it from https://github.com/openseadra 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() { ... }`. -* 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() { ... }`. \ No newline at end of file +* 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); +```