DS Server

Javascript: SubTextPart.scrollTo Method

Method|Introduced in 28.0

Description

Sets the current input position to the beginning of a subtextpart and scrolls it into the visible part of the document.

Syntax

<void> SubTextPart.scrollTo(<RequestBooleanCallback> callback, [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
callback

Receives whether the call was succesful.

errorCallback

Optional. Is called when the operation failed with an error.

Examples

The following example demonstrates SubTextPart.scrollTo in a practical document-editing workflow. It sets the current input position to the beginning of a subtextpart and scrolls it into the visible part of the document.

function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

TXTextControl.textParts.getMainText(function(mainText) {
    const subTextParts = mainText.subTextParts;
    subTextParts.getItem(function(subTextPart) {
        if (!subTextPart) {
            console.warn("No sub text part is available at the current input position.");
            return;
        }
    
        subTextPart.scrollTo(
            function(result) {
                if (result) {
                    console.log("scroll to is available.");
                } else {
                    console.warn("scroll to is not available in the current document state.");
                }
            },
            onTxError
        );
    }, onTxError);
}, onTxError);