1.0.1 • Published 7 years ago

clicky v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

Clicky

Use clicky to invoke a callback after a user has clicked around your site/application a certain amount of times.

If you feel the need (or are forced to) implement some kind of marketing modal or popup, this is a better alternative to timer based events.

Usage

const clicky = new Clicky()

clicky.setOptions({
  threshold: 10,
  callback: () => {
    alert('You have clicked 10 times!')
  }
})

Options

OptionDescriptionDefault
thresholdThe amount of clicks until callback is invoked5
localStorageNameOverride the name for the localStorage item_ClickyClickCounter
callbackA function to be invoked when the threshold is metconsole.log('Clicky threshold reached')

API

- clicky.setOptions(object)

Takes an object of options to override any defaults

- clicky.clickCount()

Returns the current click count, even after threshold has been reached

- clicky.threshold()

Returns the set threshold

- clicky.incrementClickCount(n)

Programatically increment the click count

- clicky.reset()

Reset the counters back to 0