Wraps an HTMLElement as Visual.
Type Details
- yFiles module
- view
Constructors
Static Methods
Creates a new TypedHtmlVisual<TElement> for the given element
.
Remarks
The purpose of this factory method is to get an instance of HtmlVisual but with a better matching type for the element property.
Note that this method still returns an instance of the HtmlVisual class, since TypedHtmlVisual<TElement> is just a typeScript type. The main benefit is the added type-safety.
Type Parameters
- TElement
- The type of the element, which will typically be inferred from the argument.
Parameters
A map of options to pass to the method.
- element - TElement
- The element to wrap.
Returns
- ↪TypedHtmlVisual<TElement>
- A properly typed HtmlVisual for the given element.
See Also
Creates a new TaggedHtmlVisual<TElement,TTag> for the given element
and tag
object.
Remarks
The purpose of this factory method is to get an instance of HtmlVisual but with a better matching type of the element property and the ability to store a user-provided object as tag with type-safety.
Note that this method still returns an instance of the HtmlVisual class, since TaggedHtmlVisual<TElement,TTag> is just a typeScript type. The main benefit is the added type-safety.
Type Parameters
- TElement
- The type of the element, typically inferred from the first argument.
- TTag
- The type of the cache value, typically inferred from the second argument.
Parameters
A map of options to pass to the method.
- element - TElement
- The element to wrap.
- tag - TTag
- The object to set to the HtmlVisual as tag.
Returns
- ↪TaggedHtmlVisual<TElement,TTag>
- A properly typed HtmlVisual for the given element and tag value.
See Also
Sets the translation and size values of a given HtmlElement to the provided values so that it works well inside an HtmlVisual in a CanvasComponent.
Remarks
This implementation uses caching if possible and thus performs better than using the plain DOM API when called frequently.
This implementation uses the style
property of the element to set the position
to absolute
and specify left
, top
, width
, and height
to specified the px
values.
Parameters
A map of options to pass to the method.
- element - HTMLElement
- The element that should be arranged in the HtmlVisual.
- layout - IRectangle
- The values for the rectangle.
Sets the translation and size values of a given HtmlElement to the provided values so that it works well inside an HtmlVisual in a CanvasComponent.
Remarks
This implementation uses caching if possible and thus performs better than using the plain DOM API when called frequently.
This implementation uses the style
property of the element to set the position
to absolute
and specify left
, top
, width
, and height
to specified the px
values.
Parameters
A map of options to pass to the method.
- element - HTMLElement
- The element that should be arranged in the HtmlVisual.
- dx - number
- The offset on the x-axis.
- dy - number
- The offset on the y-axis.
- width - number
- The width to set to the element.
- height - number
- The height to set to the element.
Sets the translation values of a given HtmlElement to the provided values so that it works well inside an HtmlVisual in a CanvasComponent.
Remarks
Parameters
A map of options to pass to the method.
- element - HTMLElement
- The element that should be translated.
- dx - number
- The offset on the x-axis.
- dy - number
- The offset on the y-axis.