BVB Source Codes

in-view Show viewport.js Source code

Return Download in-view: download viewport.js Source code - Download in-view Source code - Type:.js
  1. /**
  2. * Check whether an element is in the viewport by
  3. * more than offset px.
  4. */
  5. export function inViewport (element, options) {
  6.  
  7.     const { top, right, bottom, left, width, height } = element.getBoundingClientRect();
  8.  
  9.     const intersection = {
  10.         t: bottom,
  11.         r: window.innerWidth - left,
  12.         b: window.innerHeight - top,
  13.         l: right
  14.     };
  15.  
  16.     const threshold = {
  17.         x: options.threshold * width,
  18.         y: options.threshold * height
  19.     };
  20.  
  21.     return intersection.t > (options.offset.top    + threshold.y)
  22.         && intersection.r > (options.offset.right  + threshold.x)
  23.         && intersection.b > (options.offset.bottom + threshold.y)
  24.         && intersection.l > (options.offset.left   + threshold.x);
  25.  
  26. }
  27.  
downloadviewport.js Source code - Download in-view Source code
Related Source Codes/Software:
magictools - 2017-01-09
elm-compiler - Compiler for Elm, a functional language for reliab... 2017-01-09
Twig - Twig, the flexible, fast, and secure template lang... 2017-01-09
android-testing - A collection of samples demonstrating different fr... 2017-01-09
lib-flexible - Scalable layout scheme 2017-01-09
sinon - Test spies, stubs and mocks for JavaScript. ... 2017-01-09
docker-gitlab - Dockerized GitLab http://www.da... 2017-01-09
Side-Menu.Android - Side menu with some categories to choose. ... 2017-01-09
libsodium - A modern and easy-to-use crypto library. 2017-01-09
prerender - Node server that uses phantomjs to render a javasc... 2017-01-09
discover-flask - Full Stack Web Development with Flask. ... 2017-01-12
spring-mvc-showcase - Demonstrates the features of the Spring MVC web fr... 2017-01-12
tushare - TuShare is a utility for crawling historical data ... 2017-01-12
raml-spec - RAML Specification http://raml.... 2017-01-12
android-stackblur - Android StackBlur is a library that can perform a ... 2017-01-12
sound-redux - A Soundcloud client built with React / Redux ... 2017-01-12
httpstat - curl statistics made simple 2017-01-12
vim - Vim configuration file and plug-ins 2017-01-12
appframework - The definitive HTML5 mobile javascript framework ... 2017-01-12
BaiduExporter - Assistant for Baidu to export download links to ar... 2017-01-11

 Back to top