Code Monkey home page Code Monkey logo

leftyrighty.js's Introduction

LeftyRighty.js

LeftyRighty is a plugin developed by Dave Berning to make the mobile web easier to use for everyone. LeftyRighty will flip important elements in a row (Bootstrap 3) to make crucial elements easier to reach with one hand. LeftyRighty was built for the physically disabled and handicapped.

This was inspired by looking at mobile heat maps of comfortable thumb reaches for larger devices. Tapping on an important CTA on the right side of the screen is very difficult for someone with only a left hand to do. LeftyRighty will flip that CTA to make it easier for that individual.

Getting Started

LeftyRighty is built using the jQuery library and with a grid layout in mind. LeftyRighty supports Bootstrap columns (not by default) and rows. When developing your website, you should be developing your mobile site with a defeault hand in mind; default is right, unless specified left. You can flip an entire row, flip the first and last items, or flip two specific items in a row. You can also nest rows inside of rows and make each of them behave differently or not at all.

Usage

Connect your JavaScript and CSS dependancies and initialize.

Dependancies

<link rel="stylesheet" href="css/lefty-righty.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="js/lefty-righty.min.js"></script>

<script>
    $('body').leftyrighty();
</script>

HTML Structure

LeftyRighty was built with a grid format in mind. Meaning, for this to work, you'll need to code your website with rows and columns. LeftyRighty does support Bootstrap through the API.

Without Bootstrap (Default)

Basic row structure with LeftyRighty's .lr-item class.

<div class="row">
    <div class="lr-item">
        Column 1
    </div>
    
    <div class="lr-item">
        Column 2
    </div>
    
    <div class="lr-item">
        Column 3
    </div>
</div>

With Bootstrap (via API option)

If you are using Bootstrap, you will need to initialize the plugin with the Bootstrap API call.

<div class="row">
    <div class="col-sm-4">
        Column 1
    </div>
    
    <div class="col-sm-4">
        Column 2
    </div>
    
    <div class="col-sm-4">
        Column 3
    </div>
</div>

<script>
    $('body').leftyrighty({
        bootstrap: true // API call
    });
</script>

There are three main core functions that LeftyRighty supports. These can be nested and mixed and matched for greater control.

  1. Flip the entire row
  2. Flip the first and last item of the row
  3. Flip two specific items in a row

These functions can be done by simply adding a class to the row or in the third case, an item.

Row Reverse
<div class="row lr-reverse">
    <!-- columns -->
</div>
Flip First and Last Item
<div class="row lr-first-last">
    <!-- columns -->
</div>
Flip Two Specific Items

Add the .lr-spec class to two items you want to flip on click.

<div class="row">
    <div class="lr-item">
        Column 1
    </div>
    
    <div class="lr-item lr-spec">
        Column 2
    </div>
    
    <div class="lr-item">
        Column 3
    </div>
    
    <div class="lr-item">
        Column 4
    </div>
    
    <div class="lr-item lr-spec">
        Column 5
    </div>
    
    <div class="lr-item">
        Column 6
    </div>
</div>

API (Options)

Option Default Value Type
bootstrap false Boolean
showPopup true Boolean
defaultHand "right" String
showToggleButton true Boolean
showOptimizationNotice true Boolean
popupDelay 1500 Int
showPopupOnce true Boolean
addClassToFlipped true Boolean
mobileOnly true Boolean

Contributions

Fork and submit pull requests! This is a one man operation and any feedback or improvements will not only help the project, but the people that are relying on this.

Changelog

V1: Initial launch

leftyrighty.js's People

Contributors

daveberning avatar

Stargazers

 avatar

Watchers

 avatar  avatar

leftyrighty.js's Issues

Refactor code. Allow multiple selectors when initializing.

JavaScript needs to be refactored to allow multiple selectors when initializing. Ideally, these selectors will be the class or ID of the button element.

These should be able to have different options. Clicking on a button with one class will do one thing, another classes performs other actions.

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.