get_imageHorizontalAlignment();
set_imageHorizontalAlignment(value);
Object.defineProperty('imageHorizontalAlignment');
Type | Description |
---|---|
ControlAlignment | The horizontal alignment for the image in this control. Default value is ControlAlignment.Near (left). |
Changing the value of this property will fire the PropertyChanged and TransformChanged events.
Use ImageVerticalAlignment to set the vertical alignment for the image in the control.
Start with the ImageViewer example, remove all the code inside the example function (search for the "// TODO: add example code here" comment) and insert the following code:
Open the HTML page in your browser. Now when you click the Example button, the horizontal and vertical alignment values will change.
example: function SiteLibrary_DefaultPage$example(viewer) { // Loop through the image horizontal and vertical alignments var horizontalAlignment = viewer.get_imageHorizontalAlignment(); var verticalAlignment = viewer.get_imageVerticalAlignment(); if(horizontalAlignment == lt.Controls.ControlAlignment.near) horizontalAlignment = lt.Controls.ControlAlignment.center; else if(horizontalAlignment == lt.Controls.ControlAlignment.center) horizontalAlignment = lt.Controls.ControlAlignment.far; else if(horizontalAlignment == lt.Controls.ControlAlignment.far) horizontalAlignment = lt.Controls.ControlAlignment.near; if(verticalAlignment == lt.Controls.ControlAlignment.near) verticalAlignment = lt.Controls.ControlAlignment.center; else if(verticalAlignment == lt.Controls.ControlAlignment.center) verticalAlignment = lt.Controls.ControlAlignment.far; else if(verticalAlignment == lt.Controls.ControlAlignment.far) verticalAlignment = lt.Controls.ControlAlignment.near; // Show the values in the label var controlAlignmentNames = [ "Near", "Center", "Far" ]; var exampleLabel = document.getElementById("exampleLabel"); exampleLabel.textContent = controlAlignmentNames[horizontalAlignment] + " and " + controlAlignmentNames[verticalAlignment]; // Set the new values in viewer viewer.set_imageHorizontalAlignment(horizontalAlignment); viewer.set_imageVerticalAlignment(verticalAlignment); },