Start an animation on this element using the given key frames.
frames := KeyFrames([
KeyFrame("0%", ["transform": "scale(1)"]),
KeyFrame("50%", ["transform": "scale(1.1)"]),
KeyFrame("100%", ["transform": "scale(1)"]),
])
animate(frames, null, 5sec)
animate(frames, ["animation-iteration-count":"infinite"], 1sec)
Stop the current animation on this element, or do nothing if no animation in progress.
Get the given HTML attribute value for this element. Returns
null
if attribute not defined.
Get name:value
map of all attributes.
Remove focus from this elem.
Traverses this element and its parents (heading toward the
document root) until it finds a node that matches the
specified CSS selector. Returns null
if none found.
Return a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object:
this < that => <0
this == that => 0
this > that => >0
This method may also be accessed via the <
<=
<=>
>=
and >
shortcut operators. If not overridden the default
implementation compares the toStr
representations. Also see docLang.
Examples:
3.compare(8) => -1
8.compare(3) => 1
8.compare(8) => 0
3 <=> 8 => -1 // shortcut for 3.compare(8)
Return true
if given element is a descendant of this node,
or false
if not.
The enabled attribute for this element, or null if one not applicable. This is typically only valid for form elements.
The enabled attribute for this element, or null if one not applicable. This is typically only valid for form elements.
Compare this object to the specified for equality. This
method may be accessed via the == and != shortcut operators.
If not overridden the default implementation compares for
reference equality using the === operator. If this method
is overridden, then hash() must also be overridden such that
any two objects which return true for equals() must return
the same value for hash(). This method must accept null
and
return false.
Get the first child node of this element, or null if this element has no children.
Request keyboard focus on this elem.
Return true
if children is non-zero, false
otherwise.
Return true if this elem has focus.
Return a unique hashcode for this object. If a class overrides hash() then it must ensure if equals() returns true for any two objects then they have same hash code.
The HTML markup contained in this element.
The HTML markup contained in this element.
The id for this element. Returns null
if id is not defined.
The id for this element. Returns null
if id is not defined.
Get the last child node of this element, or null if this element has no children.
Get the next sibling to this element, or null if this is the last element under its parent.
The namespace URI of this element.
Attach an event handler for the given event on this element. Returns callback function instance.
Position of element relative to the whole document.
Get the parent Elem of this element, or null if this element has no parent.
Position of element relative to its parent in pixels.
Get the previous sibling to this element, or null if this is the first element under its parent.
Get the given DOM property value for this element. Returns null
if property does not exist.
Returns the first element that is a descendant of this element on which it is invoked that matches the specified group of selectors.
Remove all children from this element. Returns this.
Remove the given HTML attribute from this element.
Remove the given event handler from this element. If this handler was not registered, this method does nothing.
Paint a <canvas>
element. The given callback is invoked
with a graphics context to perform the rendering operation.
Before calling this code, you should set the canvas
width/height attributes to match the element size (typically
as a ratio of the Win.devicePixelRatio).
Scroll parent container so this Elem is visible to user. If alignToTop
is true
(the default value), the top of Elem is aligned to
top of the visible area. If false
, the bottom of Elem is
aligned to bottom of the visible area.
Optional
alignToTop: booleanTop left scroll position of element.
Scrollable size of element.
Set the given HTML attribute value for this element. If val
is null
the attribute is removed (see removeAttr).
Optionally a namespace can be specified with ns
.
Optional
ns: UriSize of element in pixels.
Get the Style instance for this element.
Get the tag name for this element.
Text content contained in this element.
Text content contained in this element.
Get an immutable representation of this instance or throw NotImmutableErr if this object cannot be represented as an immutable:
Return a string representation of this object.
Transition a set of CSS properties.
transition(["opacity": "0.5"], null, 1sec) { echo("done!") }
transition(["opacity": "0.5"], ["transition-delay": 500ms], 1sec) { echo("done!") }
The trap
operator will behave slightly differently based on
the namespace of the element.
For HTML elements, trap
works as a convenience for prop
and setProp:
div := Elem("div")
div->tabIndex = 0 // equivalent to div.setProp("tabIndex", 0)
For SVG elements (where ns is http://www.w3.org/2000/svg
),
trap
routes to attr and setAttr:
svg := Svg.line(0, 0, 10, 10)
svg->x1 = 5 // equivalent to svg.setAttr("x1", "5")
svg->y1 = 5 // equivalent to svg.setAttr("y1", "5")
svg->x2 == "10" // equivalent to svg.attr("x2")
This method called whenever an it-block is applied to an
object. The default implementation calls the function with this
,
and then returns this
.
Static
echoWrite x.toStr
to standard output followed by newline. If x
is null then print "null". If no argument is provided then
print an empty line.
Optional
x: JsObjStatic
fromStatic
fromCreate an Elem instance from a native
JavaScript DOM object. The type
may be specified to create a
subclass instance of Elem. Note if the native instance has
already been mapped to Fantom, the existing instance is
returned and type
will have no effect.
Optional
type: TypeStatic
makeCreate a new Elem in the current Doc. Optionally a namespace
can be specified with ns
.
Simple text based element.
See also: docDomkit