Callbacks


You can define callback functions by assigning methods to the FSI Viewer instance.

Using Callbacks

Method A – Create a function in window scope


Example:
<script>
   function onFSIViewerViewChanged(strView){
   console.log(strView);
}
<script>


a) assignment in Custom Tag:


Example:
<fsi-viewer onViewChanged="onFSIViewerViewChanged" […]/>


or


b) assignment in XML configuration file:


Example:
<fsi_parameter>
   <onViewChanged value="onFSIViewerViewChanged"/>
</fsi_parameter>


Method B - Assignment by parameter


Example:
oParameters= {};
oParameters.onViewChanged = function(strView){
console.log(strView);
}
 
var myViewer = new $FSI.Viewer(elContainer, oParameters);
myViewer.start();
// all callback assignments must take place before starting


Method C - Assignment by instance property


Example:
var myViewer = new $FSI.Viewer(elContainer, oParameters);
myViewer.onViewChanged = function(strView){
console.log(strView);
}
 
myViewer.start();
// all callback assignments must take place before starting


 Please note: You can modify or add new callbacks when calling changeConfig(). You cannot change, add or remove callbacks after the viewer started.



The following callback methods exist:



onReady();


Called as soon as FSI Viewer finished loading data and gets interactive.




onConfigsReady(oConfigValues);


Called as soon as FSI Viewer finished loading the configuration.




onInit();


Called as soon as FSI Viewer is initialized.




onDestroy();


Called when the fsi-viewer element is destroyed.




onInitFailed(strReason);


Called when the initialization is failed. This could happen if e.g. an image cannot be loaded or the dimensions of an image cannot be requested. The listener returns a string with the reason why the initialization failed.




onMenuEnabled(bEnabled);


Called if the menu is enabled/disabled.




onMenuReady();


Called as soon as the menu is ready.




onMenuDestroy();


Called if the menu is destroyed.




onZoomChanged(fScale, fScaleMax, fPercent);


This optional callback function will be called each time the magnification level change is finished.

fScale is the magnification level from 0 to 100.

fScaleMax sets the maximum zoom level.

fPercent is the percentage of the magnification from 0 to 100.




onZoomChanging(fScale, fScaleMax, fPercent, bPreliminary);


This optional callback function will be called each time while magnification level changed.




onAnimationComplete();


Called when a spin and/or zoom animation finishes.




onAnimationStart();


Called when a spin and/or zoom animation starts.




onChangeConfig(strCfgFileName, oParameters);


Called when the config file is changed.




onChangeImage(oParameters, strView);


Called when the image is changed.




onResize(nWidth, nHeight, bResizeDone, BFullScreen);


Called when the fsi-viewer element is resized.




onSkinChanged(strCurrentSkinClass, strCurrentSkinClassBefore)


This optional callback function can be used to call an action as soon as the skin class is changed.




onRegisterExternalMenuButtons()


This optional callback function can be used to call an action as soonexternal menu buttons are registered.




onAfterRegisterExternalButton(elButton, strButtonID, bButtonPresentInViewer)


This optional callback function can be used to remove inactive buttons from the menu bar if you are using a custom skin.




onProgress(fPercent);


This optional callback function can be called while the loading progress.




 onMenuButtonEnabled( strButtonID, null, bEnable);


This optional callback function can be used call an action when a button is enabled or disabled.




onMenuButtonPressed(strButtonID, evt);


This optional callback function can be used to set an action that starts when a button is pressed.




onMenuButtonReleased(strButtonID, evt);


This optional callback function can be used to set an action when a certain button is released..




onMenuButtonClicked(strButtonID, evt);


This optional callback function can be used to set an action when a certain button is released..




onMenuButtonSetPressed(bPressed);


This optional callback function can be used to call an action when a button is pressed.




onMenuButtonMouseDown(strButtonID, evt);


This optional callback function can be used to call an action when a mouse button is pressed.




onReset();


This optional callback function can be used to call an action when the configuration is changed.




onAfterReady();


This optional callback function can be used to call an action after the instance is ready.




onInitMenu();


This optional callback function can be used to set an action when the menu is built (after all buttons are added).




 onLanguageData(oLanguageItems );


This optional callback function can be used to set an action when the language data is loaded.





onMouseModeChanged(nMouseMode);


This optional callback function can be used to call an action when the mouse mode is changed.




onStartDragging(bInNavWindow);


This optional callback function can be used to call an action when the user starts dragging the image.




onStopDragging(bInNavWindow);


This optional callback function can be used to call an action when the user stops dragging the image.




onDataComplete();


This optional callback function can be used to call an action while the configuration data loading is completed. Images/videos are not loaded yet at this point.




onFullScreen(bFullScreenActive);


This optional callback function can be used to call an action when FullScreen mode is enabled or disabled.




onViewChanged(strViewString);


This optional callback function can be used to call an action as soon as the viewed image section changes.




onClickDemoMode(url, targetFrame);


This optional callback function can be used to call an action as soon as the demo mode instance is clicked on. (You need to return "false" in order to prevent default action!)




onEnterDemoMode();


This optional callback function can be used to call an action as soon as the demo mode is entered.




onExitDemoMode();


This optional callback function can be used to call an action as soon as the demo mode is left.




on3DWorldChanged(o3DData);


This optional callback function is called each time the 3D world parameters like rotation or dimension change. oData.projection provides access to the three.js objects (camera, scene, renderer and objects). oData.scenes contains information about the FSI Viewer scenes and scene sets.




onInit3D(oProjection);


This optional callback function is called once the three.js scene (camera, scene, renderer and objects) has been created. The oProjection argument provides access to the three.js objects. You might for example add additional 3D objects to oProjection.objects or oProjection.scene.




onHotspotEvent(strAction, nHotspotID, strHotspotAttributeID, strContent, event)


This optional callback function can be used to call an action as soon as a certain Hotspot event occurs. The following events are possible: mouseover, mousedown, mouseout & click.





onMeasureChange(fLength, fRotation, strLabel)


This optional callback function can be used to call an action as soon the measurement is changed. RETURN: strModifiedLabel




onMeasureEnd(fLength, fRotation, strLabel, arCoords)


This optional callback function can be used to call an action as soon as a the measurement ends.




onMeasureShow(bShow)


This optional callback function can be used to call an action as soon as the measurement is displayed.




onMeasureStart(fLength, fRotation, strLabel)


This optional callback function can be used to call an action as soon as the measurement process is started.




onMeasureUpdateRatio(fLengthFactor, fImageRealWidth, fImageWidth)


This optional callback function can be used to call an action as soon as the measurement reference is updated due to a change of the original image ratio.