DocuVieware Reference Guide
Reference Guides > JavaScript API > Events > RegisterOnRotationChanged

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

RegisterOnRotationChanged: function (docuViewareID, callback)


The identifier for the DocuVieware™ instance.
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 () {
}, false);