Coder Social home page Coder Social logo

taytus / sticky-sidebar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from abouolia/sticky-sidebar

0.0 1.0 0.0 84 KB

jQuery plugin for making smart and high performance sticky sidebar. :scream:

Home Page: https://abouolia.github.io/sticky-sidebar/

License: MIT License

JavaScript 100.00%

sticky-sidebar's Introduction

Sticky Sidebar

jQuery plugin for making smart and high performance sticky sidebars.

Basic Example

Scrollable Sticky Element

Multiply Sticky Elements

See for complete documents and examples abouolia.github.com/sticky-sidebar

Install

You can download sticky sidebar jquery plugin from Bowser, NPM or just simply download it from here than put sticky-sidebar.js file in your project folder.

Bower

If you are using bower as package manager:

bower install sticky-sidebar

NPM

If you are using NPM as package manager:

npm install sticky-sidebar

Usage

Your website's html structure has to be similer to this in order to work:

<div class="main-content">
    <div class="sidebar">
        <div class="sidebar__inner">
            <!-- Content goes here -->
        </div>
    </div>
    <div class="content">
        <!-- Content goes here -->
    </div>
</div>

Note that inner sidebar wrapper .sidebar__innner is optional but highly recommended, if you don't write it yourself, the script will create one for you. but this may cause many problems.

For the above example, you can use the following JavaScript:

<script type="text/javascript" src="./js/jquery.js"></script>
<script type="text/javascript" src="./js/sticky-sidebar.js"></script>

<script type="text/javascript">
    $(document).ready(function(){
        $(".sidebar").stickySidebar({
            containerSelector: '.main-content',
            innerWrapperClass: 'sidebar__inner'
        });	
    });
</script>

Make sure to include sticky-sidebar.js script file after jquery.js.

Via data attributes

To easily configure sticky sidebar to any element on the document using attributes, just add data-sticky-sidebar attribute with no value to element that you want to make it sticky. You can also configure its options, for example topSpacing option add it as attribute on element like that data-top-spacing="50"

Either by configure container of sticky element by adding data-sticky-sidebar-container attribute to container of sticky element. Below code will give you

<div class="container" data-sticky-sidebar-container>
    <div class="sidebar" data-sticky-sidebar data-top-spacing="50">
    	<!-- Content Goes Here -->
    </div>
    <div class="content">
    	<!-- Content Goes Here -->
    </div>
</div>	

Broswers Support

Compatible with Firefox, Chrome, Safari, and IE9+. We looking forward to support IE8+.

License

Sticky Sidebar is released under the MIT license. Have at it.


Made by Ahmed Bouhuolia

sticky-sidebar's People

Contributors

abouolia avatar

Watchers

Roberto Inetti 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.