0.3.1 • Published 10 years ago

browser-viewport v0.3.1

Weekly downloads
2
License
MIT
Repository
github
Last release
10 years ago

browser-viewport

Browser viewport lib – smooth scrolling and viewport operating methods

Installation

npm install browser-viewport --save

Usage

You can use library to smooth scrolling or detecting element in viewport or no

var viewport = require('browser-viewport');
var element = document.querySelector('#some-element-id');
viewport.scrollTop(500, 1000);

Methods

scrollTo(element, duration)

Little helper to do smooth scroll to element with duration of 700 ms

  • element - DOM element to scroll to

scrollTop(offset, duration)

Do window smooth scrolling to offset

  • offset - scroll to that offset from top
  • duration - how smooth your scroll? in ms

isIn(element)

Check if element is visible in current viewport

  • element - DOM element to check

width()

Get current viewport width

height()

Get current viewport height

0.3.1

10 years ago

0.3.0

10 years ago

0.2.2

10 years ago

0.2.0

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago