The SVGSVGElement
interface provides access to the properties of <svg>
elements, as well as methods to manipulate them. This interface contains also various miscellaneous commonly-used utility methods, such as matrix operations and the ability to control the time of redraw on visual rendering devices.
This interface also inherits properties from its parent, SVGGraphicsElement
and also implements the ones from SVGZoomAndPan
, SVGFitToViewBox
, and WindowEventHandlers
.
SVGSVGElement.x
Read only
SVGAnimatedLength
corresponding to the x
attribute of the given <svg>
element.SVGSVGElement.y
Read only
SVGAnimatedLength
corresponding to the y
attribute of the given <svg>
element.SVGSVGElement.width
Read only
SVGAnimatedLength
corresponding to the width
attribute of the given <svg>
element.SVGSVGElement.height
Read only
SVGAnimatedLength
corresponding to the height
attribute of the given <svg>
element.SVGSVGElement.contentScriptType
SVGAnimatedLength
corresponding to the contentScriptType
attribute of the given <svg>
element.SVGSVGElement.contentStyleType
SVGAnimatedLength
corresponding to the contentStyleType
attribute of the given <svg>
element.SVGSVGElement.viewport
SVGRect
containing the position and size of the viewport (implicit or explicit) that corresponds to the given <svg>
element. When the browser is actually rendering the content, then the position and size values represent the actual values when rendering. The position and size values are unitless values in the coordinate system of the parent element. If no parent element exists (i.e., <svg>
element represents the root of the document tree), if this SVG document is embedded as part of another document (e.g., via the HTML <object>
element), then the position and size are unitless values in the coordinate system of the parent document. (If the parent uses CSS or XSL layout, then unitless values represent pixel units for the current CSS or XSL viewport.)SVGSVGElement.pixelUnitToMillimeterX
SVGSVGElement.pixelUnitToMillimeterY
SVGSVGElement.screenPixelToMillimeterX
SVGSVGElement.screenPixelToMillimeterY
SVGSVGElement.useCurrentView
<svg>
element such as viewBox
) or on a "custom" view (i.e., a hyperlink into a particular <view>
or other element). If the initial view is the "standard" view, then this attribute is false
. If the initial view is a "custom" view, then this attribute is true
.SVGSVGElement.currentView
SVGViewSpec
defining the initial view (i.e., before magnification and panning) of the current innermost SVG document fragment. The meaning depends on the situation: If the initial view was a "standard" view, then: viewBox
, preserveAspectRatio
and zoomAndPan
within currentView
will match the values for the corresponding DOM attributes that are on SVGSVGElement
directlytransform
and viewTarget
within currentView
will be null<view>
element, then: viewBox
, preserveAspectRatio
and zoomAndPan
within currentView
will correspond to the corresponding attributes for the given <view>
elementtransform
and viewTarget
within currentView
will be null<view>
), then: viewBox
, preserveAspectRatio
and zoomAndPan
within currentView
will match the values for the corresponding DOM attributes that are on SVGSVGElement
directly for the closest ancestor <svg>
elementtransform
within currentView
will be nullviewTarget
within currentView
will represent the target of the linkviewBox
, preserveAspectRatio
, zoomAndPan
, transform
and viewTarget
within currentView
will correspond to the values from the SVG view specification fragment identifierSVGSVGElement.currentScale
<svg>
element, this float attribute indicates the current scale factor relative to the initial view to take into account user magnification and panning operations. DOM attributes currentScale
and currentTranslate
are equivalent to the 2x3 matrix [a b c d e f] = [currentScale 0 0 currentScale currentTranslate.x currentTranslate.y]
. If "magnification" is enabled (i.e., zoomAndPan="magnify"
), then the effect is as if an extra transformation were placed at the outermost level on the SVG document fragment (i.e., outside the outermost <svg>
element).SVGSVGElement.currentTranslate
Read only
SVGPoint
representing the translation factor that takes into account user "magnification" corresponding to an outermost <svg>
element. The behavior is undefined for <svg> elements that are not at the outermost level.This interface also inherits methods from its parent, SVGGraphicsElement
and also implements the ones from SVGZoomAndPan
, SVGFitToViewBox
, and WindowEventHandlers
.
SVGSVGElement.suspendRedraw()
Takes a time-out value which indicates that redraw shall not occur until:
the corresponding unsuspendRedraw() call has been made, an unsuspendRedrawAll() call has been made, or its timer has timed out.In environments that do not support interactivity (e.g., print media), then redraw shall not be suspended. Calls to suspendRedraw()
and unsuspendRedraw()
should, but need not be, made in balanced pairs.
To suspend redraw actions as a collection of SVG DOM changes occur, precede the changes to the SVG DOM with a method call similar to:
suspendHandleID = suspendRedraw(maxWaitMilliseconds);
and follow the changes with a method call similar to:
unsuspendRedraw(suspendHandleID);
Note that multiple suspendRedraw calls can be used at once and that each such method call is treated independently of the other suspendRedraw method calls.
SVGSVGElement.unsuspendRedraw()
suspendRedraw()
by providing a unique suspend handle ID that was returned by a previous suspendRedraw()
call.SVGSVGElement.unsuspendRedrawAll()
suspendRedraw()
method calls. This method is most useful at the very end of a set of SVG DOM calls to ensure that all pending suspendRedraw()
method calls have been cancelled.SVGSVGElement.forceRedraw()
SVGSVGElement.pauseAnimations()
<svg>
element, causing the animation clock corresponding to this document fragment to stand still until it is unpaused.SVGSVGElement.unpauseAnimations()
SVGSVGElement.animationsPaused()
SVGSVGElement.getCurrentTime()
<script>
element before the document's SVGLoad event is dispatched), then 0 is returned.SVGSVGElement.setCurrentTime()
setCurrentTime
is called before the document timeline has begun (for example, by script running in a <script>
element before the document's SVGLoad event is dispatched), then the value of seconds in the last invocation of the method gives the time that the document will seek to once the document timeline has begun.SVGSVGElement.getIntersectionList()
NodeList
of graphics elements whose rendered content intersects the supplied rectangle. Each candidate graphics element is to be considered a match only if the same graphics element can be a target of pointer events as defined in pointer-events
processing.SVGSVGElement.getEnclosureList()
NodeList
of graphics elements whose rendered content is entirely contained within the supplied rectangle. Each candidate graphics element is to be considered a match only if the same graphics element can be a target of pointer events as defined in pointer-events
processing.SVGSVGElement.checkIntersection()
true
if the rendered content of the given element intersects the supplied rectangle. Each candidate graphics element is to be considered a match only if the same graphics element can be a target of pointer events as defined in pointer-events
processing.SVGSVGElement.checkEnclosure()
true
if the rendered content of the given element is entirely contained within the supplied rectangle. Each candidate graphics element is to be considered a match only if the same graphics element can be a target of pointer events as defined in pointer-events
processing.SVGSVGElement.deselectAll()
SVGSVGElement.createSVGNumber()
SVGNumber
object outside of any document trees. The object is initialized to a value of zero.SVGSVGElement.createSVGLength()
SVGLength
object outside of any document trees. The object is initialized to a value of zero user units.SVGSVGElement.createSVGAngle()
SVGAngle
object outside of any document trees. The object is initialized to a value of zero degrees (unitless).SVGSVGElement.createSVGPoint()
SVGPoint
object outside of any document trees. The object is initialized to the point (0,0) in the user coordinate system.SVGSVGElement.createSVGMatrix()
SVGMatrix
object outside of any document trees. The object is initialized to the identity matrix.SVGSVGElement.createSVGRect()
SVGRect
object outside of any document trees. The object is initialized such that all values are set to 0 user units.SVGSVGElement.createSVGTransform()
SVGTransform
object outside of any document trees. The object is initialized to an identity matrix transform (SVG_TRANSFORM_MATRIX
).SVGSVGElement.createSVGTransformFromMatrix()
SVGTransform
object outside of any document trees. The object is initialized to the given matrix transform (i.e., SVG_TRANSFORM_MATRIX
). The values from the parameter matrix are copied, the matrix parameter is not adopted as SVGTransform::matrix
.SVGSVGElement.getElementById()
Specification | Status | Comment |
---|---|---|
Scalable Vector Graphics (SVG) 2 The definition of 'SVGSVGElement' in that specification. | Candidate Recommendation | Replaced the inheritance from SVGElement by SVGGraphicsElement , removed the implemented interfaces SVGTests , SVGLangSpace , SVGExternalResourcesRequired , SVGStylable , SVGLocatable , DocumentEvent , ViewCSS , and DocumentCSS and added implemented interface WindowEventHandlers . |
Scalable Vector Graphics (SVG) 1.1 (Second Edition) The definition of 'SVGSVGElement' in that specification. | Recommendation | Initial definition |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | Yes | Yes | Yes | 9 | Yes | Yes |
animationsPaused |
? | ? | ? | ? | ? | ? |
checkEnclosure |
? | ? | No | ? | ? | ? |
checkIntersection |
? | ? | No | ? | ? | ? |
contentScriptType |
? | Yes | ? — 20 | ? | ? | ? |
contentStyleType |
? | Yes | ? — 20 | ? | ? | ? |
createSVGAngle |
? | ? | ? | ? | ? | ? |
createSVGLength |
? | ? | ? | ? | ? | ? |
createSVGMatrix |
? | ? | ? | ? | ? | ? |
createSVGNumber |
? | ? | ? | ? | ? | ? |
createSVGPoint |
? | ? | ? | ? | ? | ? |
createSVGRect |
? | ? | ? | ? | ? | ? |
createSVGTransform |
? | ? | ? | ? | ? | ? |
createSVGTransformFromMatrix |
? | ? | ? | ? | ? | ? |
currentScale |
? | ? | ? | ? | ? | ? |
currentTranslate |
? | ? | ? | ? | ? | ? |
currentView |
? — 56 | No | Yes | ? | ? — 43 | ? |
deselectAll |
? | ? | ? | ? | ? | ? |
forceRedraw
|
? | ? | ? | ? | ? | ? |
getCurrentTime |
? | ? | ? | ? | ? | ? |
getElementById |
Yes | Yes | 11 | ? | Yes | ? |
getEnclosureList |
? | ? | No | ? | ? | ? |
getIntersectionList |
? | ? | No | ? | ? | ? |
height |
? | ? | ? | ? | ? | ? |
pauseAnimations |
? | ? | ? | ? | ? | ? |
pixelUnitToMillimeterX
|
? — 47 | Yes | ? — 61 | ? | ? — 33 | ? |
pixelUnitToMillimeterY
|
? — 47 | Yes | ? — 61 | ? | ? — 33 | ? |
screenPixelToMillimeterX
|
? — 47 | Yes | ? — 61 | ? | ? — 33 | ? |
screenPixelToMillimeterY
|
? — 47 | Yes | ? — 61 | ? | ? — 33 | ? |
setCurrentTime |
? | ? | ? | ? | ? | ? |
suspendRedraw
|
? | ? | ? | ? | ? | ? |
unpauseAnimations |
? | ? | ? | ? | ? | ? |
unsuspendRedraw
|
? | ? | ? | ? | ? | ? |
unsuspendRedrawAll
|
? | ? | ? | ? | ? | ? |
useCurrentView |
? — 56 | No | 15 | ? | ? — 43 | ? |
viewport |
? | ? | ? | ? | ? | ? |
width |
? | ? | ? | ? | ? | ? |
x |
? | ? | ? | ? | ? | ? |
y |
? | ? | ? | ? | ? | ? |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | ? | Yes | Yes | Yes | Yes | Yes | ? |
animationsPaused |
? | ? | ? | ? | ? | ? | ? |
checkEnclosure |
? | ? | ? | No | ? | ? | ? |
checkIntersection |
? | ? | ? | No | ? | ? | ? |
contentScriptType |
? | ? | Yes | ? | ? | ? | ? |
contentStyleType |
? | ? | Yes | ? | ? | ? | ? |
createSVGAngle |
? | ? | ? | ? | ? | ? | ? |
createSVGLength |
? | ? | ? | ? | ? | ? | ? |
createSVGMatrix |
? | ? | ? | ? | ? | ? | ? |
createSVGNumber |
? | ? | ? | ? | ? | ? | ? |
createSVGPoint |
? | ? | ? | ? | ? | ? | ? |
createSVGRect |
? | ? | ? | ? | ? | ? | ? |
createSVGTransform |
? | ? | ? | ? | ? | ? | ? |
createSVGTransformFromMatrix |
? | ? | ? | ? | ? | ? | ? |
currentScale |
? | ? | ? | ? | ? | ? | ? |
currentTranslate |
? | ? | ? | ? | ? | ? | ? |
currentView |
? — 56 | ? — 56 | No | Yes | ? — 43 | ? | ? |
deselectAll |
? | ? | ? | ? | ? | ? | ? |
forceRedraw
|
? | ? | ? | ? | ? | ? | ? |
getCurrentTime |
? | ? | ? | ? | ? | ? | ? |
getElementById |
Yes | Yes | Yes | ? | Yes | ? | ? |
getEnclosureList |
? | ? | ? | No | ? | ? | ? |
getIntersectionList |
? | ? | ? | No | ? | ? | ? |
height |
? | ? | ? | ? | ? | ? | ? |
pauseAnimations |
? | ? | ? | ? | ? | ? | ? |
pixelUnitToMillimeterX
|
? — 47 | ? — 47 | Yes | ? — 61 | ? — 33 | ? | ? |
pixelUnitToMillimeterY
|
? — 47 | ? — 47 | Yes | ? — 61 | ? — 33 | ? | ? |
screenPixelToMillimeterX
|
? — 47 | ? — 47 | Yes | ? — 61 | ? — 33 | ? | ? |
screenPixelToMillimeterY
|
? — 47 | ? — 47 | Yes | ? — 61 | ? — 33 | ? | ? |
setCurrentTime |
? | ? | ? | ? | ? | ? | ? |
suspendRedraw
|
? | ? | ? | ? | ? | ? | ? |
unpauseAnimations |
? | ? | ? | ? | ? | ? | ? |
unsuspendRedraw
|
? | ? | ? | ? | ? | ? | ? |
unsuspendRedrawAll
|
? | ? | ? | ? | ? | ? | ? |
useCurrentView |
? — 56 | ? — 56 | No | 15 | ? — 43 | ? | ? |
viewport |
? | ? | ? | ? | ? | ? | ? |
width |
? | ? | ? | ? | ? | ? | ? |
x |
? | ? | ? | ? | ? | ? | ? |
y |
? | ? | ? | ? | ? | ? | ? |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/SVGSVGElement