Coder Social home page Coder Social logo

factor1 / nifty-nav Goto Github PK

View Code? Open in Web Editor NEW
2.0 6.0 0.0 76 KB

NO LONGER MAINTAINED - A handy dandy jQuery plugin that allows your navigation to slide up or down.

CSS 19.56% JavaScript 30.10% HTML 50.33%
navigation hamburger nav-items navigation-drawer

nifty-nav's People

Contributors

erwstout avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

nifty-nav's Issues

Remove Example from Repo

The example in the repo is extremely out of date and should be removed (or updated but dont see that happening, really...)

Why prevent following parent links when sub menus set to true

By default, subMenuParentLink is false, but why is this the case? A parent link in a menu is still a valid link, and the user expects this to be followed if they click on it. I understand if this was implemented to make it easier for the sub-menu functionality to work, for example

niftyNav({
  subMenus: true,
  subMenuParentLink: true,
});

leads to behavior where the link is followed and the sub menu will toggle open.

This functionality may need to be updated to allow for both following parent links and toggling sub menus independently.

Restructure Plugin

Should restructure plugin to have /src/ and /dist/ with a proper gulp.js file.

Update CSS for header

Currently Nifty Nav uses this code

header{
  z-index: $header-index;
}

but this should probably be namespaced in some way. In its current state, it is applying this z-index to any header in the site, and this can potentially cause unexpected issues in other areas, for example any header that may be placed inside on an article, main, etc.

Add panel height option

To make it more flexible, would be good to add a $panel-height option in the settings. Default value could be 100%, but easy access to change when sites need a full screen menu of 100vh or something.

Add support for button text

Currently, the toggle button assumes that it will always be a hamburger icon, and adding text alongside of the hamburger icon requires basically a custom implementation in order to keep the icon and text in the same element.

This should probably be updated to easily allow text to be shown alongside the hamburger icon.

subMenuParentLink

This option is on by default, but is preventing the parent nav items from being followed in a standard dropdown implementation. It is targeting all parent links on the page instead of being isolated to just those inside of nifty nav itself.

if( subMenuParentLink === false ){
      $('.menu-item-has-children > a').click(function(event){
        event.preventDefault();
      });
    }

should be more like

if( subMenuParentLink === false ){
      $('.nifty-panel .menu-item-has-children > a').click(function(event){
        event.preventDefault();
      });
    }

Don't close sub-menus automatically?

Currently, if a menu has sub-menus, and you click on a sub-menu item to navigate to a page you get a weird behavior of the sub-menu closing and then the page navigates to where ever you clicked. This is not a bug, but it could be better.

This code is likely the culprit of this behavior:

$nifty_parent.click(function(){
  $nifty_parent_active = $(this);
  $nifty_parent_active.find('.sub-menu').slideToggle(300);
  $nifty_parent_active.toggleClass('nifty-menu-opened');
});

When clicking on a nav item the user is really clicking on the a element. $nifty_parent is set here $nifty_parent = $('.nifty-panel ul li');. So since the click listener is on the li the code $nifty_parent_active.find('.sub-menu').slideToggle(300); gets triggered by way of bubbling.

I think that if either the bubbling is stopped when clicking an anchor or if this piece of code is extracted if would be a better experience.

preventDefault on subMenus

When subMenus is true Nifty Nav uses preventDefault to disable the parent nav item from clicking through to the link (if there is one). This may cause issues for some users on desktop who wish to allow parent items to be clickable.

Should think about adding a preventDefault: false option if users want to turn off this feature.

Current work around for allowing link clicks on desktop and submenus on mobile:

  $window = window.innerWidth;
  if( $window <= 688 ){
    niftyNav({
      subMenus: true
    });
  } else{
    niftyNav();
  }

Adjust Hamburger to allow larger click area

Currently the <a> anchor is controlling the position but it would be better to allow that to be 100%/100% to have a larger click area and then adjust the span, span:before, span:after classes to align better and use those for positioning.

[Urgent] Latest Update was Unintended Breaking Change

The last nifty nav update was an unintended breaking change and needs to be rolled back ASAP. Rolling back, issuing a patch, and then bumping the version to a new major version should fix the install issues that have been cropping up here and there when installing projects via npm install

Class being applied when it shouldnt

Noticed a bug with Tonik, when subMenus are set to true. Clicking on any link applies the class nifty-menu-opened to that links parent list item, but I think that this should only happen if that link is also in a sub-menu. This code would need to be adjusted, as it ends up looking for any anchor in the entire menu instead of just anchors in a sub-menu:

screen shot 2017-04-03 at 3 19 04 pm

The issue this causes is evident in this image:

screen shot 2017-04-03 at 3 24 57 pm

I had styled the caret down to appear on list items that have the class nifty-menu-opened assuming that class would only ever be applied to list items that contained sub-menus, but since every list item is given that class when clicking on the anchor it causes the offset seen in News & Events. My CSS has been adjusted for this, but this will still need to be corrected in the code.

Plans to make Nifty Nav a true jQuery function?

In its current state Nifty Nav is a function that relies on jQuery. It works so no issue there, but why not just make it a true jQuery function so you can choose what element is will act upon? Example $(item).niftyNav();

For our sites there is usually one sliding menu, but if there is ever a design that needs more than one the current implementation no longer works, as all menus will have the exact same properties.

A true jQuery plugin set up will allow for more than one menu/panel, and will also allow for situations when someone wants to chain additional jQuery methods to the Nifty Nav. Example niftyNav().css('color', 'red'); would cause an error while $(item).niftyNav().css('color', 'red'); will work fine.

Add default sub-menu styling

Currently there is no default styling for submenus. Currently with this code

niftyNav({
  subMenus: true,
});

the submenus still display on the page, and clicking the parent hides them.

CSS should be added to hide them with display: none by default.

Also, if this option is set to true it would be good to add a default icon or something to visualize that there is a sub menu available.

Why rely on jQuery for panel animation?

The panel reveal currently uses the jQuery slideToggle() method, but why not use CSS animations/transitions which are faster and more performant than JS for this? Also, to my knowledge, this only allows something to slide up or down, not left or right. Using CSS would open up the possibility to the panel to be revealed in any number of ways.

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.