Methods
Usually you will not need to use the javascript interface.
Even if you modify an image src
parameter at runtime, the tool will notice that and replace the magnified image accordingly.
If you on the other hand add images to the DOM tree at runtime or modify the position of images by script, the following interface is available to update the images and positions:
Initialization:
const quickId = 'fsiId-123'
addMyImagesToTheDom(quickId); // add your images here
// create and initialize FSI.QuickZoom
const instance = new $FSI.QuickZoom()
const success = instance.init(quickId, {
debug: true,
useDevicePixelRatio: true,
inPlaceZoom: false
}, false);
function addMyImagesToTheDom(quickId) {
const ele = document.createElement("img")
ele.setAttribute("src", "https://yourserver.com/fsi/server?type=image&source=images/sample.jpg&width=400")
ele.setAttribute("width", "400")
ele.setAttribute("height", "200")
ele.setAttribute("alt", "Your Sample")
ele.setAttribute("id", quickId)
document.body.appendChild(ele)
}
addImage
const image = addImage(img)
This adds a single img node to the list of quickzoom images.
instance.addImage(imgNode)
Example
tip
You can as well call scanForNewImages()
after adding an img node.
addListener
const success = addListener(listenerName, fn, iScope)
Calls a specific listener.
const success = instance.addListener('onZoomStart',
(img, zoomImg) => {
// code
})
Example
Consult Callbacks for an overview of all available listeners.
dumpListeners
dumpListeners()
Lists all listeners in the console and how often they were called.
instance.dumpListeners()
Example
getBuild
const version = getBuild()
Returns a string containing the FSI QuickZoom software build number.
const version = instance.getBuild()
Example
getConfigValue
const value = getConfigValue(name)
Returns the value of any configuration parameter addressed with `name`.
const value = instance.getConfigValue('inPlaceZoom')
Example
getImageCount
const imageAmount = getImageCount()
Returns the amount of registered images.
const imageAmount = instance.getImageCount()
Example
getInstanceID
const getID = getInstanceID()
Returns the number of the viewer object.
const getID = instance.getInstanceID()
Example
getInstanceName
const name = getInstanceName()
Returns the type of the viewer (e.g. FSI QuickZoom) and the id attribute of the viewer object.
const name = instance.getInstanceName()
Example
getParameters
const param = getParameters()
Returns an object containing all parameters set via javascript or custom tag attributes.
const param = instance.getParameters()
// return example:
/*
{
id: 'myViewer',
inplacezoom: '1'
}
*/
Example
getVersion
const version = getVersion()
Returns a string containing the FSI QuickZoom software version number.
const version = instance.getVersion()
Example
init
const success = init(id, options, debug)
Initialises the chosen viewer element.
This method is only needed if an FSI QuickZoom has not been started automatically (default).
const success = instance.init('fsi-123', {
inPlaceZoom: true,
magnification: 4,
}, true)
Example
printAPI
printAPI()
Shows all API methods, listeners and button IDs in the console in alphabetical order.
instance.printAPI()
Example
removeImages
const imageAmount = removeImages(img)
Removes one or more QuickZoom images and restores their original state.
const imageAmount = instance.removeImages('imageID','imageID2')
Example
removeListener
const success = removeListener(listenerName, fn)
Removes a specific listener.
const success = instance.removeListener('onZoomEnd', yourFunction)
Example
testAPIListenersStart
testAPIListenersStart()
Starts the API test and shows all called listeners and the parameters which they return.
instance.testAPIListenersStart()
Example
testAPIListenersStop
testAPIListenersStop()
Stops the API test.
instance.testAPIListenersStop()
Example
traceConfigValue
const show = traceConfigValue(name)
Traces a config value and enables you to see where (by parameter/attribute, in config files, the _default.xml, etc) a specific value is set.
const show = $FSI.quickZoom.traceConfigValue('inPlaceZoom')
// return example:
// Tracing parameter "inPlaceZoom"
// https://yourdomain.com/fsi/viewer/_default.xml
// <QuickZoom/>
// <inPlaceZoom value="true"></inPlaceZoom>
// RESULT:
// inplacezoom = "true"
Example
scanForNewImages
scanForNewImages()
Calling the scanForNewImages method will make the script look for responsive images that have not been present in the DOM tree when the document finished loading.
instance.scanForNewImages()
Example
If you e.g. add img tags at runtime, you need to call this method in order to make the script aware of new image(s).