Git Product home page Git Product logo

greedynav's Introduction

Greedy Navigation

Include greedynav.css and greedynav.js on the page and put the <nav> code in the body of the document. When the user resizes the window the nav will shrink, any overflowing items will be removed from the visible list and get prepended to a list of vertically stacked items that are hidden. The user is notified of this action by a count badge next to a hamburger icon at the end of the menu, which acts as a dropdown trigger button for the hidden list.

Demo

http://codepen.io/lukejacksonn/pen/BowbWE

Usage

<head>
<link href="greedynav.css" rel="stylesheet" type="text/css" >
<script src="greedynav.js"></script>
</head>
<body>
<nav class='greedy'>
  <h1>GreedyNav</h1>
  <ul class='links'>
    <li><a href='#'>navbar</a></li>
    <li><a href='#'>that</a></li>
    <li><a href='#'>handles</a></li>
    <li><a href='#'>overflowing</a></li>
    <li><a href='#'>menu</a></li>
    <li><a href='#'>elements</a></li>
    <li><a href='#'>effortlessly</a></li>
  </ul>
  <button>MENU</button>
  <ul class='hidden-links hidden'></ul>
</nav>
</body>

TODO

  • Extend demo to show varients
  • Make into a web component

greedynav's People

Contributors

atelierbram avatar coliff avatar lukejacksonn avatar pjbaert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

greedynav's Issues

Floating the menu on the left

I couldn't find a way to have this menu left aligned and the dropdown also left aligned always close to the last menu item, anyone found a solution for this?

IE9

Does not work?

.links li don't visible.

horizontal

How would you make this nav bar horizontal instead of vertical?

Incorrect resizing when the window is maximized

Hello,

Great project!

I noticed one issue though, and maybe it would be easier to explain it by just mentioning how to reproduce it:

  1. Open a site which uses GreedyNav (even the examples will do, http://codepen.io/lukejacksonn/pen/BowbWE )
  2. Resize down the browser window. Greedy nav starts to correctly hide items
  3. Once several items are hidden, maximize the browser window.

Expected behavior:
All items in the navigation bar are now correctly displayed, as the window is maximized.

Actual behavior:
The navbar seems to update at some intermediary state, as only part of the navigation items are visible after the window was maximized, while others are still hidden.

Screenshot (1080x1920 monitor, full screen):

image

I assume it happens because the resize listener fires off in a weird way when a maximize is being performed, however I'm not a web dev so I don't know how to fix it myself in order to submit a pull request.

Kind regards,
CataJ

Upload to CDN

Would be great to be able to fetch this from some CDN...

react version

Has anybody tried to port this to React? I'm having issues doing it so. My main concern is: measuring the DOM elements has to be done on componentDidMount but what if a stylesheet (remote with link tag) is affecting the sizes of the menu elements? How do we know when a CSS has been applied to the DOM in componentDidMount?

How to not count submenus items

Hi, i posted this to codepen also. I hope is ok to post here too.
I want to use this nav with submenus, but not to count them in counter. Is it possible?
Tnx

`check()` doesn't seem to run properly on page load

Initially when the page loads, there can be overlapping navigation items (the A in about is cut off):
img_3804

However, if I scroll down and then back up, an event must get triggered because the navigation items stop overlapping:
img_3805

I have only been able to reproduce this issue on mobile.

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.