jQuery stayStill v1.0.0

View on GitHub

Demo

This plugin's purpose is to avoid getting lost when content is added to the page.
Click on the "eye" button to show hidden kittens on the page.
The plugin will avoid the page to scroll and what was in the middle of the screen will stay there.

Set-up

<!-- insert jQuery stayStill after jQuery core -->
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="https://cdn.rawgit.com/jadus/jquery-stayStill/v1.0.0/jquery.stayStill.min.js"></script>

Usage

<!-- add the "stay-still" class to the elements you want to keep still -->
<div class="container">
    <div class="stay-still">
        content1
    </div>
    <div class="stay-still">
        content2
    </div>
    <!-- more elements -->
</div>

// call the saveState method juste before changing the page content
$(".container").stayStill('saveState');

// do something here like adding elements to the page

// call the resetState method just after changing the page content (in a callback if your changes are async)
$(".container").stayStill('resetState');

About

This is my second open source project.
Feel free to make comments, raise bugs and ask for features.
This plugin is used on skipass.com but on an admin only page.
I'd be glad to know if you use it.
You could be interested by my other plugin which offers a intuitive way to sort elements in a page :
jQuery sortScroll