https://github.com/WeCodePixels/theia-sticky-sidebar
Glues your website's sidebars, making them permanently visible while scrolling.
https://github.com/WeCodePixels/theia-sticky-sidebar
javascript scrolling sidebar sidebar-height ux website-sidebars
Last synced: 10 months ago
JSON representation
Glues your website's sidebars, making them permanently visible while scrolling.
- Host: GitHub
- URL: https://github.com/WeCodePixels/theia-sticky-sidebar
- Owner: WeCodePixels
- License: mit
- Created: 2014-04-03T00:13:37.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2024-07-24T16:52:15.000Z (over 1 year ago)
- Last Synced: 2024-10-10T12:39:39.347Z (over 1 year ago)
- Topics: javascript, scrolling, sidebar, sidebar-height, ux, website-sidebars
- Language: JavaScript
- Homepage:
- Size: 1.2 MB
- Stars: 570
- Watchers: 36
- Forks: 209
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Theia Sticky Sidebar
A JavaScript library that glues your website's sidebars (or any vertical column for that matter), making them permanently visible when scrolling up and down. Useful when a sidebar is too tall or too short compared to the rest of the content. Works with virtually any design and supports multiple sidebars.
## WordPress
[](https://wecodepixels.com/shop/theia-sticky-sidebar-for-wordpress/)
Also available as a [premium WordPress plugin](https://wecodepixels.com/shop/theia-sticky-sidebar-for-wordpress/) that comes with a user-friendly admin panel and supports a plethora of themes out-of-the-box.
## Examples
[3 columns example](http://theia-sticky-sidebar.wecodepixels.com/examples/3-columns.html)
[4 columns example](http://theia-sticky-sidebar.wecodepixels.com/examples/4-columns.html)
[Bootstrap 4 example](http://theia-sticky-sidebar.wecodepixels.com/examples/bootstrap-v4.html)
[Foundation example](http://theia-sticky-sidebar.wecodepixels.com/examples/foundation.html)
## Install
### Bower
If you are using Bower as your package manager:
```bash
bower install theia-sticky-sidebar
```
### NPM
If you are using NPM as your package manager:
```bash
npm install theia-sticky-sidebar
```
## Usage
Your website's HTML structure has to be similar to this in order to work:
```html
```
Note that the inner "theiaStickySidebar" divs are optional, but highly recommended.
If you don't supply them yourself, the script will create them for you, but this can be problematic
if you're using ads or iframes, since they will be moved around in the DOM and as a result will get reloaded.
**Note:** Make sure to use `` in your page, otherwise you might run into weird issues.
For the above example, you can use the following JavaScript:
```html
jQuery(document).ready(function() {
jQuery('.content, .sidebar').theiaStickySidebar({
// Settings
additionalMarginTop: 30
});
});
```
### ResizeSensor
Theia Sticky Sidebar uses the [CSS Element Queries](https://github.com/marcj/css-element-queries) library to detect when your sidebars change height, so that it can recalculate their positions. This can happen if you are using an [accordion](http://v4-alpha.getbootstrap.com/components/collapse/#accordion-example), for example.
You can choose **not** to include the `ResizeSensor.min.js` script in your page, in which case Theia Sticky Sidebar will continue to function (possibly even a bit smoother) but will not automatically detect height changes.
## Settings
### containerSelector
The sidebar's container element. If not specified, it defaults to the sidebar's parent.
### additionalMarginTop
An additional top margin in pixels. Defaults to **0**.
### additionalMarginBottom
An additional bottom margin in pixels. Defaults to **0**.
### updateSidebarHeight
Updates the sidebar's height. Use this if the background isn't showing properly, for example. Defaults to **true**.
### minWidth
The sidebar returns to normal if its width is below this value. Useful for responsive designs. Defaults to **0**.
### disableOnResponsiveLayouts
Try to detect responsive layouts automatically and disable the sticky functionality on smaller screens. More exactly, it detects when the container and the sidebar are moved one on top of the other, instead of showing up side-by-side. Defaults to **true**.
### defaultPosition
The sidebar must have a non-static `position`, as the inner sticky-sidebar uses `position: absolute`. Defaults to **relative**.
### namespace
Events are binded using a namespace, so that you may unbind them later on without affecting others. Defaults to **TSS**.
## Credits
Stock photos courtesy of [Unsplash.com](https://unsplash.com/)