This is a jQuery plugin that creates a dynamic menu with a triangle pointer based on clip-path.



Installation
Node
$ npm install triangle-menu --save
Then require it:
;
and use:
$myElement;
Browser
Download triangle-menu.min.js (minified) or menu-triangle.js (dev) and add it to you HTML file:
Remember about dependencies (http://jquery.com/download and clip-path-polygon)!
Compilation
If you want to compile the whole package and run unit tests, type npm install
and grunt
.
Usage
Definition:
triangleMenu(options)
where options are not required.
You have to have a certain HTML structure to use it. All the items in the menu have to have .menu-item
class.
Options
Option | Type | Default | Description |
---|---|---|---|
triangleHeight |
number | 20 | Height of the clipped triangle in px |
triangleWidth |
number | 50 | Width of the clipped triangle in px |
menuItemSelector |
string | .menu-item | Selector of the submenu item |
activate(event, index) |
function | nothing | The callback function that is called when the mouse hovers over a .menu-item element; index argument is the index of .menu-item element and it's numerated from 1 |
Example use:
You can find the working examples here.
1 2 3 4
and in your javascript file:
;
you can add some css to see the effects:
More examples
With Bootstrap2:
1 2 3
Using options:
;```