distanceFromElementTopToViewportTop

Type:Function
Status:stable
Since:1.0.0
Platform:js
@blackbyte.sugar.js.dom.distance

This function take an element as parameter and returns you to distance it has from the element top to the viewport top in pixels

Params

  1. $elm*-HTMLElement

    The element you want to get the distance from

Return

  1. -Number

    The calculated distance

Example

import { distanceFromElementTopToViewportTop } from '@blackbyte/sugar/dom';
distanceFromElementTopToViewportTop(myElement); // => 23