In This Topic
Reference Guides / JavaScript API / Events / RegisterOnRotationChanged

RegisterOnRotationChanged

In This Topic
 RegisterOnRotationChanged

This function allows you to trigger a function of your own when the rotation change event is fired.

RegisterOnRotationChanged: function (docuViewareID, callback)

Parameters

docuViewareID
The identifier for the DocuVieware™ instance.
callback
The function you want to execute on event.
The callback provides an integer as argument, this is the numeric value of a GdPictureRotateFlipType enumeration member that represents the current rendering rotation.
Basically 0 means no rotation, 1 means 90° clockwise rotation, 2 means 180° rotation and 3 means 270° clockwise (or 90° counterclockwise) rotation.

Return Value

1 if error.

Example of usage

This JavaScript makes sure the DocuVieware control is properly loaded and initialized and then subscribes to the event on load.

function RegisterOnRotationChangedOnDocuViewareAPIReady() {
    if (typeof DocuViewareAPI !== "undefined" && DocuViewareAPI.IsInitialized("DocuVieware1")) {
        DocuViewareAPI.RegisterOnRotationChanged("DocuVieware1", function (rotation) { console.log(rotation); });
    }
    else {
        setTimeout(function () { RegisterOnRotationChangedOnDocuViewareAPIReady() }, 10);
    }
}
document.addEventListener("DOMContentLoaded", function () {
    RegisterOnRotationChangedOnDocuViewareAPIReady();
}, false);