@@ -18,6 +18,9 @@ var zoom = (function(){
1818 var panEngageTimeout = - 1 ,
1919 panUpdateInterval = - 1 ;
2020
21+ // Timeout for call back function
22+ var callbackTimeout = - 1 ;
23+
2124 // Check for transform support so that we can fallback otherwise
2225 var supportsTransforms = 'WebkitTransform' in document . body . style ||
2326 'MozTransform' in document . body . style ||
@@ -159,12 +162,18 @@ var zoom = (function(){
159162 /**
160163 * Zooms in on either a rectangle or HTML element.
161164 *
165+ * (necessary)
162166 * @param {Object } options
167+ *
168+ * (necessary)
163169 * - element: HTML element to zoom in on
164170 * OR
165171 * - x/y: coordinates in non-transformed space to zoom in on
166172 * - width/height: the portion of the screen to zoom in on
167173 * - scale: can be used instead of width/height to explicitly set scale
174+ *
175+ * (optional)
176+ * - callback: call back when zooming in ends
168177 */
169178 to : function ( options ) {
170179
@@ -209,19 +218,37 @@ var zoom = (function(){
209218 } , 800 ) ;
210219
211220 }
221+
222+ if ( ! ! options . callback ) {
223+ callbackTimeout = setTimeout ( function ( ) {
224+ options . callback ( ) ;
225+ } , 800 ) ;
226+ }
212227 }
213228 }
214229 } ,
215230
216231 /**
217232 * Resets the document zoom state to its default.
233+ *
234+ * (optional)
235+ * @param {Object } options
236+ * - callback: call back when zooming out ends
237+ *
218238 */
219- out : function ( ) {
239+ out : function ( options ) {
220240 clearTimeout ( panEngageTimeout ) ;
221241 clearInterval ( panUpdateInterval ) ;
242+ clearTimeout ( callbackTimeout ) ;
222243
223244 magnify ( { x : 0 , y : 0 } , 1 ) ;
224245
246+ if ( typeof options !== "undefined" && typeof options . callback !== "undefined" ) {
247+ setTimeout ( function ( ) {
248+ options . callback ( ) ;
249+ } , 800 ) ;
250+ }
251+
225252 level = 1 ;
226253 } ,
227254
0 commit comments