js-smart-hint

1.0.17 • Public • Published

Smart Hint.

Simple, lightweight pure JavaScript component that implement customizable re-positioning hint.

Demo

https://jagermesh.github.io/js-smart-hint/

Usage:

  1. Include the script:
<script type="text/javascript" src="smart-hint.js"></script>
  1. Create SmartHint instance
const hint = new SmartHint();
  1. Attach where needed
hint.attach('.has-hint');
  1. Customize if needed
hint.attach('.has-custom-hint', {
  getContent: function(selector) {
    return new Promise(function(resolve) {
      resolve('Hint Text');
    });
  },
  beautify: function(hintOverlay, selector) {
    hintOverlay.style.fontSize = `${Math.floor(Math.random() * 10)+8}pt`;
    hintOverlay.style.backgroundColor = 'red';
    hintOverlay.style.color = 'white';
  }
});

That's all.

Have fun. Send PR if you find any glitches or want to make improvements.

:)

Readme

Keywords

Package Sidebar

Install

npm i js-smart-hint

Weekly Downloads

414

Version

1.0.17

License

MIT

Unpacked Size

24.6 kB

Total Files

7

Last publish

Collaborators

  • jagermesh