dom-viewport
Measure and notify element regions inside the viewport (window).
Concept
//Get element bounds relative to the viewport.var rect = viewport;
//Determine wheter specified rect, with the optional inset is visible inside the viewport.var visible = viewport;
//Observe element and notify changes to the delegate.var region = viewport; //Get region visibility.regionvisible; //Get region bounds rect.regionbounds; //Dispose and stop Observe region.region;
Examples
//Implement the delegate with visibility, position and size.var delegate = { //Element is visible. } { //Element is hidden. } { //Wiewport scrolled and element has new position. } { //Wiewport resized and element has new size. };//Create a new region for element.var region = viewport;
//Create a region with 10 pixels inset.var inset = top:10 right:10 bottom:10 left:10;var region = viewport;