VisualViewport Class
The visual viewport of a document (https://drafts.csswg.org/cssom-view/#the-visualviewport-interface): the layout viewport without its scrollbars (the initial containing block computed by the layout: the clientWidth and clientHeight of the root element), magnified by the pinch zoom of the user (see UserInput.Pinch). Only the visual viewport of a top-level document is zoomed: it is then smaller than the layout viewport, and it is scrolled in the layout viewport (its VisualViewport.OffsetLeft and VisualViewport.OffsetTop) by the scrolls of the user, before the layout viewport. It fires scroll and scrollend events when its offset changes, and resize events when its size changes (the size of the viewport, its classic scrollbars, or the pinch zoom).
public sealed class VisualViewport : EventTarget- Inheritance
EventTargetVisualViewport
Properties
| Name | Description |
|---|---|
| Height | Gets the height of the visual viewport (https://drafts.csswg.org/cssom-view/#dom-visualviewport-height): see VisualViewport.Width. |
| OffsetLeft | Gets the offset of the left edge of the visual viewport from the left edge of the layout viewport: 0 unless the user zoomed in (see UserInput.Pinch), or 0 when the document is not fully active. |
| OffsetTop | Gets the offset of the top edge of the visual viewport from the top edge of the layout viewport: see VisualViewport.OffsetLeft. |
| OnResize | Gets or sets the event handler of the resize event. |
| OnScroll | Gets or sets the event handler of the scroll event. |
| OnScrollEnd | Gets or sets the event handler of the scrollend event. |
| PageLeft | Gets the x coordinate of the left edge of the visual viewport relative to the initial containing block: the scroll position of the layout viewport plus VisualViewport.OffsetLeft (Window.ScrollX), or 0 when the document is not fully active. |
| PageTop | Gets the y coordinate of the top edge of the visual viewport relative to the initial containing block: see VisualViewport.PageLeft. |
| Scale | Gets the scale of the visual viewport: the page scale of a top-level document on a mobile device (set by its viewport meta element, see ViewportOptions.IsMobile) multiplied by the pinch zoom of the user (see UserInput.Pinch), or 0 when the document is not fully active. |
| Width | Gets the width of the visual viewport (https://drafts.csswg.org/cssom-view/#dom-visualviewport-width): the width of the viewport without the rendered vertical classic scrollbar, divided by VisualViewport.Scale (the layout is computed when it is out of date), or 0 when the document is not fully active. On a mobile device (ViewportOptions.IsMobile), the visual viewport of a top-level document is the viewport of the device scaled by the page scale. |
Height
CssomView.Scrolling.csGets the height of the visual viewport (https://drafts.csswg.org/cssom-view/#dom-visualviewport-height): see VisualViewport.Width.
public double Height { get; }OffsetLeft
CssomView.Scrolling.csGets the offset of the left edge of the visual viewport from the left edge of the layout viewport: 0 unless the user zoomed in (see UserInput.Pinch), or 0 when the document is not fully active.
public double OffsetLeft { get; }OffsetTop
CssomView.Scrolling.csGets the offset of the top edge of the visual viewport from the top edge of the layout viewport: see VisualViewport.OffsetLeft.
public double OffsetTop { get; }OnResize
CssomView.Scrolling.csGets or sets the event handler of the resize event.
Property value
See also
OnScroll
CssomView.Scrolling.csGets or sets the event handler of the scroll event.
Property value
See also
OnScrollEnd
CssomView.Scrolling.csGets or sets the event handler of the scrollend event.
Property value
See also
PageLeft
CssomView.Scrolling.csGets the x coordinate of the left edge of the visual viewport relative to the initial containing block: the scroll position of the layout viewport plus VisualViewport.OffsetLeft (Window.ScrollX), or 0 when the document is not fully active.
public double PageLeft { get; }PageTop
CssomView.Scrolling.csGets the y coordinate of the top edge of the visual viewport relative to the initial containing block: see VisualViewport.PageLeft.
public double PageTop { get; }Gets the scale of the visual viewport: the page scale of a top-level document on a mobile device (set by its viewport meta element, see ViewportOptions.IsMobile) multiplied by the pinch zoom of the user (see UserInput.Pinch), or 0 when the document is not fully active.
public double Scale { get; }Gets the width of the visual viewport (https://drafts.csswg.org/cssom-view/#dom-visualviewport-width): the width of the viewport without the rendered vertical classic scrollbar, divided by VisualViewport.Scale (the layout is computed when it is out of date), or 0 when the document is not fully active. On a mobile device (ViewportOptions.IsMobile), the visual viewport of a top-level document is the viewport of the device scaled by the page scale.
public double Width { get; }