LEADTOOLS JavaScript (Leadtools.Controls)

ImageHorizontalAlignment Property

Show in webframe
Example 
Gets or sets a value that indicates the horizontal alignment for the image in this control.
Syntax
get_imageHorizontalAlignment();
set_imageHorizontalAlignment(value);
Object.defineProperty('imageHorizontalAlignment');

Property Value

TypeDescription
ControlAlignmentThe horizontal alignment for the image in this control. Default value is ControlAlignment.Near (left).
Remarks

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.

Example

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);
},
See Also

Reference

ImageViewer Object
ImageViewer Members

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.