Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

okaynav-js

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

okaynav-js

VPenkov's vanilla okayNav

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

okaynav

Progressively Collapsing Navigation Links

NPM Version Build Status Chat room

okaynav is a responsive and mobile-friendly navigation plugin that automatically hides overflowing items and shows them in a off-canvas sidebar navigation when screen's size is too small to fit all menu items.

okaynav demo

Usage

<header>
	<h1>Logo</h1>
	<nav id="navigation">
		<ul>
			<li><a href="/shop">Shop</a></li>
			<li><a href="/blog">Blog</a></li>
			...
		</ul>
	</nav>
</header>
var okaynav = new OkayNav(target, options);
target

Type: Selector || Element

The element containing navigation items.

Options

Optionally, you may override any of okaynav’s configuration.

measure

Type: Selector || Element
Default: target.parentNode

The element whose width and children’s widths determine the overflow.

items

Type: Selector || Array-like
Default: target.querySelector("li")

The items which may be overflowed.

toggle

Type: Selector || Element
Default: target.appendChild(document.createElement("ul")

The element toggling the visibility of overflowed navigation.

overflow

Type: Selector || Element
Default: target.appendChild(document.createElement("ul"))

The element containing overflowed items.

toggleContent

Type: HTML || Element
Default:

The contents of the toggle element.

priority

Type: Attribute || Function
Default: data-order

The method used to prioritize navigation items from being overflowed.

Events

okaynav dispatches many bubbling custom events you may find useful.

okaynav:initialized

Dispatched from the target when okaynav is activated.

okaynav:removeitem

Dispatched from an item when it is hidden from the navigation.

okaynav:additem

Dispatched from an item when it is added back to the navigation.

okaynav:showtoggle

Dispatched from the target when the toggle element becomes visible.

okaynav:hidetoggle

Dispatched from the target when the toggle element becomes hidden.

okaynav:showoverflow

Dispatched from the target when the overflow navigation becomes visible.

okaynav:hideoverflow

Dispatched from the target when the overflow navigation becomes hidden.

Accessibility

ARIA attributes are automatically added to and toggled on elements to improve the accessibility of overflowed navigation.

  • The toggle element is given an aria-expanded attribute which is true when overflowed navigation is visible and false when it is hidden.

  • The toggle element is given an aria-expanded attribute which is true when overflowed navigation is visible and false when it is hidden.

aria-haspopup="true"

aria-label="submenu"

FAQs

Package last updated on 29 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc