Giter VIP home page Giter VIP logo

jquery.jknav's Introduction

jQuery.jkNav

Smoothly navigate up and down between different elements on a page, even elements that are not siblings or not related! jkNav is not a static script, meaning that it will continue to search for elements that match the criteria you provide (so if an element is added after jkNav is implemented, jkNav will still catch it). For a live example, check out my personal blog.

Required Files

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.jkNav.js"></script>

Usage Example (short form)

$.jkNav('#header, #content li, #footer'); /* Navigate between anything that matches these selectors */

Usage Example (long form)

$.jkNav({
  selector: '#header, #content li, #footer',  /* Navigate between anything that matches these selectors */
  up: 75,   /* Go up when the K button is pressed (keycode is 75) */
  down: 74,   /* Go down when the J button is pressed (keycode is 74) */
  padding: 5,   /* Adds a space of 5px between the top of the element and the top of the window */
});

The selector must be defined to work but the others are optional. By default, the up button is the K button, the down button is the J button, and there is 0 padding.

Current Limitations / Ideal Future

  • If a navigable item is next in the index but is relatively or absolutely positioned, it will navigate up or down to get to it, even if the user would like to go in the opposite direction. It is advised to place the positioned element in your code relative to your index if possible.
  • Currently only up and down but maybe I'll add options to go left and right and diagonally.
  • I would like to make the padding feature able to use a function so you could make the padding conditional based on the element and such.

License: Public Domain

Please don't rename it or change credit away from me, James Anthony Bruno, because that would make me sad. It is fine, however, to make changes to jkNav's core to suit your needs for use in your products (whether commercial, personal, or non-profit). If you believe you've found a better way for jkNav to work, go ahead and message me and let me know! I would love to implement your fix.

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.