Giter Site home page Giter Site logo

hone's Introduction

Hone

Hone is the best backdrop and element highlighting utility available for modern browsers.

Installation

Install with NPM, Bower, or manually:

$ npm install hone -S
$ bower install hone -S

add the script tag or import/require:

<script src="node_modules/hone/dist/hone.js"></script>

<script src="bower_components/hone/dist/hone.js"></script>

<script src="resources/vender/hone.js"></script>
import Hone from 'hone';

var Hone = require('hone');

There are no dependencies!

API

Instantiate

Start by creating a new Hone instance:

import Hone from 'hone';

const lookAtMe = document.getElementById('showOff'),
    hone = new Hone(lookAtMe);

By default, when you pass an element to the constructor, the Hone instance will become visible immediately.

Options

The constructor takes some options as well. Here are the defaults:

const defaultOptions = {
    classPrefix: 'hone',    //all components are given style classes like "<prefix>-component"
    fixed: false,           //set to true if the element is position: fixed
    borderRadius: 0,        //creates rounded corners (all four or nothing)
    enabled: true,          //controls the visibility and event listeners
    padding: '0',           //adds padding around the target, same format as CSS padding rule
    fullScreen: false       //should the backdrop be full screen (for a modal window)
};

Instance Methods

The Hone instance has a minimal public API:

Method Description
Hone#hide() hides the backdrop
Hone#show() shows the backdrop
Hone#position(target?) repositions the backdrop, and can position to a new target if provided
Hone#setOptions(options) change instance options
Hone#destroy() removes all event listeners and DOM elements

Tips

  • If you are going to be repositioning the Hone instance frequently, even with new targets, create a single Hone instance and use the Hone#position(target) method to reposition instead of creating new instances for each target. (See example)
  • Both constructor parameters are optional. Not providing a target just disables the Hone instance by default.
  • Pass the enabled option into the constructor as false to initially hide the Hone instance

Examples

For an element in a fixed header:

import Hone from 'hone';

const menuItem = document.getElementById('menuItemAbout'),
    hone = new Hone(menuItem, {
        fixed: true
    });

Creating a backdrop behind a modal window:

import Hone from 'hone';

//no target required for a full screen Hone instance
const hone = new Hone({
    fullScreen: true
});

Positioning against a new target:

import Hone from 'hone';

const menuItemAbout = document.getElementById('menuItemAbout'),
    menuItemContact = document.getElementById('menuItemContact'),
    hone = new Hone(); //if no target is provided, it instantiates but does not enable

//position against first menu item
hone.position(menuItemAbout);

//wait for user input maybe? Then position against next menu item
hone.position(menuItemContact);

hone's People

Contributors

benmarch avatar kiraya avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

hone's Issues

Object.assign() not valid on IE

Hi,

I'm using angular-ui-tour, which use Hone as a dependency. Everything works great, except on Internet Explorer, where Object.assign() is not recognized.

Is there a way to get it to work with Angular on Internet Explorer ?

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.