Star Zoom API

The Star Zoom JavaScript API allows developers to interact with Star Zoom and add additional functionality.

Class StarZoom

This is the main StarZoom class.

Creating an Instance

You can create your own instances like this:

options = {}; // This would be your options object.
$('#myViewport').StarZoom(options);                  // jQuery way.
myInstance = new StarZoom($('#myViewport'),options); // 'normal' way.

Getting an Instance

You can get the Star Zoom instance that belongs to a particular viewport element:

myInstance = $('#myViewport').data('StarZoom');

Calling Methods

Once an instance has been obtained, call methods like this:

myInstance.loadImage('/someImage');
myInstance.destroy();

Calling Static Methods

Call static methods like this:

StarZoom.someStaticMethod();

Handling Star Zoom Events

Bind handlers to Star Zoom events like this:

$('#myViewport').bind('starzoom_ready',function(){alert('Star Zoom is ready!'});
Method Summary
Method Attributes Method Name and Description
 
Test API call.
 
Removes all content within the viewport and destroys the Star Zoom instance.
 

Returns the canvas element being used by the StarZoom instance.

 
Returns the number of milliseconds Star Zoom has been idle, that is, no movement or scaling.
 
Returns the opacity current opacity of the image.
 
Gets the x and y position of the image in the viewport.
 
Returns the current scale of the zoom image.
 
Clears the viewport and loads a zoomable image.
<static>  
StarZoom. .quickStart

Auto starts Star Zoom, galleries and waypoints.

<static>  
StarZoom. .setAttr

Sets the attribute name to use for defining Star Zoom options in HTML.

 
Sets a draw callback.
Event Summary
Event Attributes Event Name and Description
<static>  
StarZoom.starzoom_ready()
Fired when an image has loaded succesfully.
Class Detail
StarZoom($viewport, options)
Parameters:
{jQuery} $viewport
jQuery element to use as the viewport.
{Object} options
Options object.
Method Detail
apiTest()
Test API call. Alerts a test message confirming that the API is working.

destroy()
Removes all content within the viewport and destroys the Star Zoom instance.

{Object} getCanvas()

Returns the canvas element being used by the StarZoom instance.

Only applicable for Canvas-enabled browsers.

Returns:
{Object} the Canvas element

moveToWaypoint(x, y, scale, time)

Pans and zooms to the specfied position and scale, in specified time (milliseconds)

Returns:
nothing

{number} getIdle()
Returns the number of milliseconds Star Zoom has been idle, that is, no movement or scaling.
Returns:
{number} Milliseconds.

{number} getOpacity()
Returns the opacity current opacity of the image. Typically == 1, otherwise == opacity of image as it fades in.
Returns:
{number} 0-1.

{StarZoom.point} getPixelPosition()
Gets the x and y position of the image in the viewport.
Returns:
{StarZoom.point} Current position of orign of image

{number} getScale()
Returns the current scale of the zoom image.
Returns:
{number} The current scale, where 1 is equivalent to the original size of the image.

loadImage(path)
Clears the viewport and loads a zoomable image. Also shows and hides appropriate waypoint links.
Parameters:
{String} path
Path to new image directory.

<static> StarZoom.quickStart()

Auto starts Star Zoom, galleries and waypoints. It's just shortcut way of doing this:

$(".starzoom").StarZoom();
$(".starzoom-waypoint-set").StarZoomWaypoint();
$(".starzoom-gallery").StarZoomGallery();

<static> StarZoom.setAttr(attr)

Sets the attribute name to use for defining Star Zoom options in HTML.
Default is data-starzoom.

This can be useful when you don't want to use HTML5 style data attributes.
For instance, you could set the attribute name to 'rel' or 'onclick'

Parameters:
{String} attr
The name of the attribute.

setDrawCallback(callback)
Sets a draw callback. The callback will be executed every time the image is drawn. When in idling, the callback will not be called.
Parameters:
{Function} callback
Event Detail
<static> StarZoom.starzoom_ready()
Fired when an image has loaded succesfully.

Class StarZoom.point

Field Summary
Field Attributes Field Name and Description
 
x
The x value.
 
y
The y value.
Class Detail
StarZoom.point(x, y)
Generic 2d vector for passing around horizontal and vertical values. Create a point like this:
var point = new StarZoom.point(x,y);
Parameters:
x
y
Field Detail
{number} x
The x value.

{number} y
The y value.