
Product
Introducing GitHub Actions Scanning Support
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.
scrollbalance
Advanced tools
Uses position: fixed to combat unsightly gaps in multi-column layouts, when columns are of different heights.
A javascript plugin that intelligently uses position: fixed to combat unsightly gaps in multi-column layouts, when columns are of different heights. See http://gregplaysguitar.github.io/ScrollBalance.js/ for a demo.
Requires jquery version 1.7 or higher.
With npm:
npm install scrollbalance
or via cdn:
<script type="text/javascript" src="https://www.gitcdn.xyz/repo/gregplaysguitar/ScrollBalance.js/master/ScrollBalance.js"></script>
Start with side-by-side columns, for example:
<div class="column">...</div>
<div class="column">...</div>
<div class="column">...</div>
Columns could be floated, inline-block or positioned absolutely - the only requirement is that they're side-by-side on the page.
With multiple columns, the tallest will be used as the reference height which the others scroll and fix within. If there's only one column, it will scroll and fix within it's parent element.
Initialize the plugin like so:
var scrollbalance = new ScrollBalance($('.column'), {
// options
});
scrollbalance.bind();
Or with jquery:
$('.column').scrollbalance({});
var scrollbalance = $('.column').data('scrollbalance'); // access the api
minwidth
threshold
initialize: function ()
resize: function (winWidth, winHeight)
scroll: function (scrollTop, scrollLeft)
bind: function ()
unbind: function ()
disable: function ()
enable: function ()
teardown: function ()
ScrollBalance.bind() binds to the window's resize and scroll events, but you may want to handle these manually to avoid binding to these events multiple times:
var scrollbalance = new ScrollBalance($('.column'));
$(window).on('resize', function () {
var winWidth = $(window).width();
var winHeight = $(window).height();
scrollbalance.resize(winWidth, winHeight);
// other resize behaviour
});
$(window).on('scroll', function () {
var scrollTop = $(window).scrollTop();
var scrollLeft = $(window).scrollLeft();
scrollbalance.scroll(scrollTop, scrollLeft);
// other scroll behaviour
});
To avoid changing the position of the columns, ScrollBalance.js creates a wrapper div inside each, and appends the column content dynamically. To avoid this, wrap the column content in a div with the class scrollbalance-inner and this will be used instead. The div should have no styling. E.g.
<div class="column"><div class="scrollbalance-inner">...</div></div>
<div class="column"><div class="scrollbalance-inner">...</div></div>
If your column heights change dynamically, you'll need to call the initialize method - for example:
var scrollbalance = new ScrollBalance($('.column'));
// add some content here
...
scrollbalance.initialize();
The plugin can be turned on and off with the enable
and disable
api
methods. For example, for smaller screen sizes where the columns don't have
room to float side-by-side:
var scrollbalance = new ScrollBalance($('.column'));
$(window).on('resize', function() {
if ($(window).width() > 900) {
scrollbalance.enable();
}
else {
scrollbalance.disable();
}
});
The teardown
method removes all trace of jquery-scrollbalance from an element.
For example:
var scrollbalance = new ScrollBalance($('.column'));
scrollbalance.teardown();
See http://gregplaysguitar.github.io/ScrollBalance.js/ for a demo.
The plugin is licensed under the MIT License (LICENSE.txt).
Copyright (c) 2011 Greg Brown
FAQs
Uses position: fixed to combat unsightly gaps in multi-column layouts, when columns are of different heights.
The npm package scrollbalance receives a total of 9 weekly downloads. As such, scrollbalance popularity was classified as not popular.
We found that scrollbalance demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.
Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
Research
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.