Class VisualViewport
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The VisualViewport interface of the {{domxref("Visual Viewport API", "", "", "nocode")}} represents the visual viewport for a given window. For a page containing iframes, each iframe, as well as the containing page, will have a unique window object. Each window on a page will have a unique VisualViewport representing the properties associated with that window.
[Value("VisualViewport")]
public class VisualViewport : EventTarget
- Inheritance
-
VisualViewport
- Inherited Members
Remarks
You can get a window's visual viewport using VisualViewport.
NOTE
Only the top-level window has a visual viewport that's distinct from the layout viewport. Therefore, it's generally only the
VisualViewportobject of the top-level window that's useful. For an {{htmlelement("iframe")}}, visual viewport metrics like Width always correspond to layout viewport metrics like ClientWidth.
-Web Viewports Explainer — useful explanation of web viewports concepts, including the difference between visual viewport and layout viewport.
Constructors
VisualViewport()
public VisualViewport()
Properties
Height
The height read-only property of the VisualViewport interface returns the height of the visual viewport, in CSS pixels, or 0 if current document is not fully active.
[Value("height")]
public Number Height { get; }
Property Value
- Number
A double.
Remarks
OffsetLeft
The offsetLeft read-only property of the VisualViewport interface returns the offset of the left edge of the visual viewport from the left edge of the layout viewport in CSS pixels, or 0 if current document is not fully active.
[Value("offsetLeft")]
public Number OffsetLeft { get; }
Property Value
- Number
A double.
Remarks
OffsetTop
The offsetTop read-only property of the VisualViewport interface returns the offset of the top edge of the visual viewport from the top edge of the layout viewport in CSS pixels, or 0 if current document is not fully active.
[Value("offsetTop")]
public Number OffsetTop { get; }
Property Value
- Number
A double.
Remarks
Onresize
[Value("onresize")]
public EventHandlerNonNull Onresize { get; set; }
Property Value
Onscroll
[Value("onscroll")]
public EventHandlerNonNull Onscroll { get; set; }
Property Value
Onscrollend
[Value("onscrollend")]
public EventHandlerNonNull Onscrollend { get; set; }
Property Value
PageLeft
The pageLeft read-only property of the VisualViewport interface returns the x coordinate of the left edge of the visual viewport relative to the initial containing block origin, in CSS pixels, or 0 if current document is not fully active.
[Value("pageLeft")]
public Number PageLeft { get; }
Property Value
- Number
A double.
Remarks
PageTop
The pageTop read-only property of the VisualViewport interface returns the y coordinate of the top edge of the visual viewport relative to the initial containing block origin, in CSS pixels, or 0 if current document is not fully active.
[Value("pageTop")]
public Number PageTop { get; }
Property Value
- Number
A double.
Remarks
Scale
The scale read-only property of the VisualViewport interface returns the pinch-zoom scaling factor applied to the visual viewport, or 0 if current document is not fully active, or 1 if there is no output device.
[Value("scale")]
public Number Scale { get; }
Property Value
- Number
A double.
Remarks
Width
The width read-only property of the VisualViewport interface returns the width of the visual viewport, in CSS pixels, or 0 if current document is not fully active.
[Value("width")]
public Number Width { get; }
Property Value
- Number
A double.