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:
const quickId = 'fsiId-123'
addMyImagesToTheDom() // add your images here
// create and initialize FSI.TouchZoom
instance = new $FSI.TouchZoom()
instance.init(quickId, {
debug: true,
useDevicePixelRatio: true
}, 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)
}
addListener
const success = addListener(listenerName, fn, iScope)
const success = instance.addListener('onZoomChanged',
(scale, documentScale) => {
// code
})
Consult Callbacks for an overview of all available listeners.
addImage
const image = addImage(img)
instance.addImage(imgNode)
You can as well call scanForNewImages()
after adding an img node.
dumpListeners
dumpListeners()
instance.dumpListeners()
addImage
const image = addImage(img)
instance.addImage(imgNode)
You can as well call scanForNewImages()
after adding an img node.
getBuild
const version = getBuild()
const version = instance.getBuild()
getConfigValue
const value = getConfigValue(name)
const value = instance.getConfigValue('zoomPrecision')
getImageCount
const imageAmount = getImageCount()
const imageAmount = instance.getImageCount()
getInstanceID
const getID = getInstanceID()
const getID = instance.getInstanceID()
getInstanceName
const name = getInstanceName()
const name = instance.getInstanceName()
getParameters
const param = getParameters()
const param = $FSI.touchZoom.getParameters()
// return example:
/*
{
id: 'myViewer',
usedevicepixelratio: "true"
}
*/
getVersion
const version = getVersion()
const version = instance.getVersion()
init
const success = init(id, options, debug)
This method is only needed if an FSI TouchZoom has not been started automatically (default).
const success = instance.init('fsi-123', {
useDevicePixelRatio: true,
zoomPrecision: 4,
}, true)
lockImage
lockImage(image, lock)
instance.lockImage('imageID', true)
lockImageSourceDimension
lockImageSourceDimension(image, lock)
instance.lockImageSourceDimension('imageID', true)
lockUpdates
lockUpdates(lock)
instance.lockUpdates(true)
printAPI
printAPI()
instance.printAPI()
removeImages
const imageAmount = removeImages(img, silent)
const imageAmount = instance.removeImages('imageID','imageID2')
removeAllImages
const imageAmount = removeAllImages()
const imageAmount = instance.removeAllImages()
removeListener
const success = removeListener(listenerName, fn)
const success = instance.removeListener('onZoomChanged', yourFunction)
scanForNewImages
scanForNewImages()
instance.scanForNewImages()
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).
setZoomPrecision
setZoomPrecision(precision)
instance.setZoomPrecision(5.6)
testAPIListenersStart
testAPIListenersStart()
instance.testAPIListenersStart()
testAPIListenersStop
testAPIListenersStop()
instance.testAPIListenersStop()
traceConfigValue
const show = traceConfigValue(name)
const show = $FSI.touchZoom.traceConfigValue('useDevicePixelRatio')
// return example:
// Tracing parameter "useDevicePixelRatio"
// > By Parameter/Attribute:
// true
// RESULT:
// useDevicePixelRatio = "true"
updateImagePositions
updateImagePositions()
instance.updateImagePositions()