Coder Social home page Coder Social logo

full-screen-nav's Introduction

jQuery Full Screen Nav | Demo

The intent of this plugin is to make a <nav> menu overlay the full screen & calculate a size for links on page load and window resize. There are a few options, which are defined below.

The plugin uses rem units, so it requires at least IE 9 by default.

Installation

Expected HTML

Include a way to open the navigation menu, like so:

<a href="#" class="open-menu-btn">Menu</a>

You should markup your HTML with a basic <nav> list, like so:

<nav>
    <ul>
      <li><a href="#">Link 1</a></li>
      ...
    </ul>
</nav>

Necessary CSS

You’ll have to set the <nav> offscreen to begin with. In the demo, I do this by setting a position and pulling it offscreen:

nav {
	position: fixed;
	top:-100%;
	width:100%;
	z-index:10;
}

The "openClass" option defines what class is added when the menu is opened. By default, this is .open. You need to add some CSS to position the menu back onto the screen when this class is active:

nav.open {
	top: 0;
}

Also, you’ll need to position the close button. I do this by applying the following CSS:

a.close-menu-btn {
    position: absolute;
    top:10px; right:10px;
}

Include the plugin

Somewhere after you load jQuery, load the plugin, like so:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="/path/to/jquery.fullscreennav.js"></script>

Call the plugin (with any desired options)

Finally, call the plugin. Using default options:

$("nav").fullScreenNav();

Calling the plugin with options:

$("nav").fullScreenNav({
	"option": "optionValue",
	...
});

Options

All options are defined below with their default values.

baseFontSize: 16
baseFontSize (int or string): Used to calculate rem. If this option is "16", 1rem = 16px. Read more about rems.

closeMenuBtnText: "×"
closeMenuBtnText (string): Text for the close button when the menu opens. Default is the multiplication symbol (×).

closeMenuBtnClass: ".close-menu-btn"
closeMenuBtnClass (string): Class to add to close menu button.

fontSizeDivisor: 2.25
fontSizeDivisor (int or string): "1" would make the font-size fill all available space. I found 2.25 to be visually appealing. The larger the number, the smaller the text will become.

menuBtn: ".open-menu-btn"
menuBtn (string): Selector that, when clicked, opens the menu. You need to supply this item in your HTML (see Expected HTML).

openClass: ".open"
openClass (string) Class to add to nav menu when opening. You need to supply this in your CSS to position the <nav> on screen (see Necessary CSS).

How to Get Help

I’m happy to help where I can. Feel free to contact me using the following:

Contribution

If you have something to contribute (code improvement, new feature, bug fix), I’m all ears. Just submit a pull request. If it’s useful & doesn't add too much bloat, it should be no problem to bring that in.

Please note: this is my first jQuery plugin, so there are probably lots of areas to improve. I’m open to code suggestions!

Credits/inspiration

The concept for this navigation menu first came from [Huge Inc] (http://www.hugeinc.com), Big Spaceship and Codrops. The plugin code was started from the jQuery Boilerplate.

License

Do whatever you want (read more). If I helped you in any way (using the plugin, learning something from the code, etc), I’d love to hear about it!

Bitdeli Badge

full-screen-nav's People

Stargazers

 avatar

Watchers

 avatar

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.