viki-web-utils
Web utilities used by the Viki web app
Installation
npm install -S viki-web-utils
Documentation
For full documentation, see /docs
directory.
ScrollTracker
Keeps track of the furthest point on page that user has scrolled to (in percentage). Returns most updated value everytime percentageSeen()
is called.
Usage
import Viki from 'viki-web-utils';
const tracker = new Viki.ScrollTracker();
tracker.init();
console.log('percentage of page seen', tracker.percentageSeen())
console.log('percentage of page seen rounded to granularity of 10', tracker.percentageSeenRounded(10))
LocalStorageTabCounter
Keeps track of number of tabs user has open in current session. Saves current count to user's localStorage.
Usage
import Viki from 'viki-web-utils';
const counter = new Viki.LocalStorageTabCounter();
console.log(counter.getCount())
ResizeCounter
Tracks number of times user has resized the window. Debounced at 300ms to prevent too many function calls.
Usage
import Viki from 'viki-web-utils';
const counter = new Viki.ResizeCounter(function() {
});
console.log(counter.getCount())
Development
Install dependencies
npm install
Run tests
npm run tests
Build and publishing
npm build
npm run build-docs // generates JSDoc documentation to /docs dir
npm publish //script automatically builds before publish