0.0.11 • Published 8 years ago

raf-measure v0.0.11

Weekly downloads
1
License
MIT
Repository
-
Last release
8 years ago

rAF Measure

A utility to performantly event scroll and resize events using requestAnimationFrame. This utility also allows you know when a registered element has entered the viewport.

Usage

Registering For Scroll Events

import measurer from 'raf-measure';

let measureId = measurer.register('scroll', {
  callback({ scrollTop, scrollLeft }) {
    console.log(scrollTop, scrollLeft);
  }
} /*, optional context */);

Registering For Resize Events

import measurer from 'raf-measure';

let measureId = measurer.register('resize', {
  callback({ height, width }) {
    console.log(height, width);
  }
} /*, optional context */);

Registering For Elements In View Port

import measurer from 'raf-measure';

let measureId = measurer.register('inViewPort', {
  element: document.getElementById('my-div'),
  callback({ height, width }) {
    console.log(height, width);
  }
  // optional hitbox must return a bool
  //, hitbox({elLeft, elTop, elWidth, elHeight}, {clientX, clientY, clientWidth, clientHeight}) {}
} /*, optional context */);

Unregistering Events

import measurer from 'raf-measure';

let measureId = measurer.register('inViewPort', {
  element: document.getElementById('my-div'),
  callback({ height, width }) {
    console.log(height, width);
  }
  // optional hitbox must return a bool
  //, hitbox({elLeft, elTop, elWidth, elHeight}, {clientX, clientY, clientWidth, clientHeight}) {}
} /*, optional context */);

measurer.unregister('inViewPort', measureId);
0.0.11

8 years ago

0.0.10

9 years ago

0.0.9

9 years ago

0.0.8

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago

0.0.0

9 years ago