Methods
// create FSI Viewer element and set parameters
const instance = document.createElement("fsi-viewer")
instance.setAttribute("id", viewerId)
instance.setAttribute("src", "images/samples/shoe-brown.jpg")
instance.setAttribute("skin", "white")
instance.setAttribute("debug", true)
instance.setAttribute("plugins", "resize,fullScreen")
instance.style.width = '600px'
instance.style.height = '400px'
document.body.appendChild(instance)
// start viewer instance
instance.start()
// add method changeImage
const success = instance.changeImage({
fpxsrc: "images/samples/sneaker/sneaker-white.jpg",
effects: "contrast(10)"
},
'1,1,0.05,0.4,0.9,0.7,0'
)
// add listener onChangeImage
instance.addListener('onChangeImage', (parameters, view) => {
console.log('Image is now:', parameters, view)
})
addListener
const success = addListener(listenerName, fn, iScope)
const success = instance.addListener('onZoomChanged',
(scale, scaleMax, percent, preliminary) => {
// code
})
Consult Callbacks for an overview of all available listeners.
changeConfig
changeConfig(cfgFileName, [parameters])
instance.changeConfig('viewer_presets/no_user_interface.xml')
changeImage
const success = changeImage(parameters, [view])
const success = instance.changeImage({
fpxsrc: "images/samples/sample.png",
effects: "sepia()"
},
'1,1,0.05,0.4,0.9,0.7,0')
clickMenuButton
clickMenuButton(buttonID)
See Overview of button IDs for FSI Viewer for a list of all available IDs.
instance.clickMenuButton('ToggleFullScreen')
debugEnabled
const success = debugEnabled()
const success = instance.debugEnabled()
debugError
debugError()
instance.debugError()
debugLog
debugLog()
instance.debugLog()
debugWarn
debugWarn()
instance.debugWarn()
destroy
destroy()
instance.destroy()
dumpListeners
dumpListeners()
instance.dumpListeners()
getBuild
const version = getBuild()
const version = instance.getBuild()
getConfigValue
const value = getConfigValue(name)
const value = instance.getConfigValue('src')
getHotspotViewString
const coordinates = getHotspotViewString(hotspotID)
const coordinates = instance.getHotspotViewString('1')
See getViewString for an explanation on how the view coordinates are composed.
getImageIsTransparent
const success = getImageIsTransparent()
const success = instance.getImageIsTransparent()
getInFullScreenMode
const success = getInFullScreenMode()
const success = instance.getInFullScreenMode()
getInitDone
const success = getInitDone()
const success = instance.getInitDone()
getInstanceID
const getID = getInstanceID()
const getID = instance.getInstanceID()
getInstanceName
const name = getInstanceName()
const name = instance.getInstanceName()
getMenuButtonPresent
const success = getMenuButtonPresent(buttonID)
See Overview of button IDs for FSI Viewer for a list of all available IDs.
This can be used to remove inactive buttons from the menu if you are using a custom skin.
Method only delivers correct results after the callback onInitMenu
is called.
const success = instance.getMenuButtonPresent('HotSpots')
getMenuHeight
const height = getMenuHeight(purpose)
const height = instance.getMenuHeight()
getMouseMode
const mode = getMouseMode()
See Mouse Mode plugin for more info on mouse modes.
const mode = instance.getMouseMode()
// zoom mode
switch (mode) {
case 0: // zoom
// code
break;
case 1: // pan
// code
break;
case 2: // rotate
// code
break;
}
getParameters
const param = getParameters()
const param = instance.getParameters()
// return example:
/*
{
id: 'myViewer',
dir: 'images/samples/spin/',
cfg: 'samples/spin.xml',
autodisablepointeractions: 'true',
inplacezoom: '1'
}
*/
getPluginParameter
const param = getPluginParameter(pluginName, parameterName, [defaultValue], [makeBoolean])
const param = instance.getPluginParameter('autoSpin', 'interval')
See Plugin Parameters for an overview of all available plugins for FSI Viewer.
getSkinClassName
const skin = getSkinClassName()
const skin = instance.getSkinClassName()
getSpinFrames
const frame = getSpinFrames()
const frame = instance.getSpinFrames()
getSrcDim
const dim = getSrcDim()
const dim = viewer.getSrcDim()
/* return example:
{
width: 5184,
height: 3456
}
*/
getVersion
const version = getVersion()
const version = instance.getVersion()
getViewString
const view = getViewString()
The format is: SceneSet
, Scene
, left
, top
, right
, bottom.
SceneSet
is 1 for rotations around one axis.
Scene
describes the rotation. If you use 36 images for a spin, scene 18 means a rotation of 180 degree.
left
, top
, right
, bottom
: image coordinates in the range [0.0 to 1.0].
const view = instance.getViewString()
getVisibleImageRect
const rect = getVisibleImageRect()
const rect = instance.getVisibleImageRect()
/* return example:
{
left: 0,
top: 0.263021,
right: 1,
bottom: 0.736979
}
getVisibleImageRectParameter
const rect = getVisibleImageRectParameter()
const rect = instance.getVisibleImageRectParameter()
// return example:
// 0,0.3,1,0.3
getVisibleImageURL
const url = getVisibleImageURL(width, height, [effects], [makeImageFitInto])
const url = instance.getVisibleImageURL(200, 500, 'sepia()', true)
// or
const url = instance.getVisibleImageURL('default', 'default')
// return example:
// 'https://yourserver.com/fsi/server?width=200&effects=sepia()&type=image&source=images/samples/image.png'
getZoom
const zoom = getZoom()
const zoom = instance.getZoom()
getZoomFloat
const zoom = getZoomFloat()
const zoom = instance.getZoomFloat()
gotoHotspot
const success = gotoHotspot(hotspotID, animate, zoom)
const success = instance.gotoHotspot(2, true, true)
gotoViewString
const success = gotoViewString(view, animated)
Please refer to getViewString
to see the correct format required.
const success = instance.gotoViewString('1,15,0,0.229167,1,0.770833,0', true)
hideMenuToolTip
hideMenuToolTip()
instance.hideMenuToolTip()
init
const success = init(id, options, debug)
This method is only needed if an FSI Viewer has not been started automatically (default).
const success = instance.init('fsi-123', {
language: 'german',
imageWidth: 250,
quickZoomInPlaceZoom: true
}, true)
makeBoolean
const success = makeBoolean(value, [defaultValue])
Example: 0, "0", "false" and "FALSE" are converted to boolean false. Every number except 0, "1", "true" and "TRUE" are converted to boolean true.
const success = instance.makeBoolean('false')
pressMenuButton
pressMenuButton(buttonID)
See Overview of button IDs for FSI Viewer for a list of all available IDs.
instance.pressMenuButton('ToggleFullScreen')
printAPI
printAPI()
instance.printAPI()
registerExternalMenuButton
registerExternalMenuButton(button, buttonID, [tip])
See Overview of button IDs for FSI Viewer for a list of all available IDs.
instance.registerExternalMenuButton('zoomIt', 'ZoomIn', 'It zooms!')
registerExternalMenuButtonsFromContainer
registerExternalMenuButtonsFromContainer(container)
instance.registerExternalMenuButtonsFromContainer('buttonContainer')
releaseMenuButton
releaseMenuButton(buttonID)
See Overview of button IDs for FSI Viewer for a list of all available IDs.
instance.releaseMenuButton('ToggleFullScreen')
removeListener
const success = removeListener(listenerName, fn)
const success = instance.removeListener('onZoomChanged', yourFunction)
resetView
resetView()
instance.resetView()
setFullScreenElement
const success = setFullScreenElement(FSContainer)
const success = instance.setFullScreenElement('buttonContainer')
setMouseMode
setMouseMode(mode)
See Mouse Mode plugin for more info on mouse modes.
instance.setMouseMode('3')
setZoom
setZoom(percent, preliminary, animate)
instance.setZoom('50', true, true)
showMenuButton
showMenuButton(buttonID, show)
See Overview of button IDs for FSI Viewer for a list of all available IDs.
instance.showMenuButton('ToggleFullScreen', false)
showMenuToolTip
showMenuToolTip(tip, src, x, y)
instance.showMenuToolTip('foo', btn, 0, 0)
spinToDegree
spinToDegree(degree)
instance.spinToDegree(180)
spinToTarget
spinToTarget(targetFrame, [targetSceneSet], [frames])
instance.spinToTarget(2, 1, 12)
startAutoSpin
const success = startAutoSpin()
const success = instance.startAutoSpin()
stopAutoSpin
const success = stopAutoSpin()
const success = instance.stopAutoSpin()
testAPIListenersStart
testAPIListenersStart()
instance.testAPIListenersStart()
testAPIListenersStop
testAPIListenersStop()
instance.testAPIListenersStop()
traceConfigValue
const show = traceConfigValue(strName)
const show = instance.traceConfigValue('src')
// return example:
// Tracing parameter "src"
// By Parameter/Attribute:
// images/samples/bag.png
// RESULT:
// src (alias: fpxsrc) = "images/samples/bag.png"
unregisterExternalMenuButton
const success = unregisterExternalMenuButton(button)
const success = instance.unregisterExternalMenuButton('zoomIt')
unregisterExternalMenuButtonsFromContainer
unregisterExternalMenuButtonsFromContainer(container)
instance.unregisterExternalMenuButtonsFromContainer('buttonContainer')