VisualViewport Class
The visual viewport of a document (https://drafts.csswg.org/cssom-view/#the-visualviewport-interface): there is no pinch zoom, so it is the layout viewport without its scrollbars (the initial containing block computed by the layout: the clientWidth and clientHeight of the root element), a scale of 1, no offset from the layout viewport, and the scroll position of the layout viewport as page offsets. It is never scrolled relative to the layout viewport, so it never fires scroll nor scrollend events; it fires resize events when its size changes (the size of the viewport, or its classic scrollbars).
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, there is no pinch zoom. |
| OffsetTop | Gets the offset of the top edge of the visual viewport from the top edge of the layout viewport: 0, there is no pinch zoom. |
| 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), else 1 (there is no pinch zoom), 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, there is no pinch zoom.
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: 0, there is no pinch zoom.
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), else 1 (there is no pinch zoom), 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; }