How to make a custom music Equalizer with jQuery
July 1st, 2011 - Frontend, Javascript, jQuery - 1 Comments

Music on websites is kind of a deprecated concept nowadays, but for those clients who absolutely must have it or or that funky web radio station that needs a custom player, there is no reason not to follow the latest standards using HTML5 and JavaScript. In this micro tutorial we ‘ll see how we can implement a simple pseudo-equalizer in our player of choice using just CSS and jQuery.
The HTML
The markup is straightforward, just a simple container with a new element for each of our bars.
<div class="eq">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</div>
Styling our bars
We can now use whatever styling we need to make the equalizer up to par with our player and website. I chose to use a simple green color for demonstration purposes:
.bar {
background-color: green;
width:7px;
height:15px;
display: inline-block;
vertical-align: bottom;
}
The important thing here to notice is the vertical-align: bottom; rule. Without it, the equalizer animation behaves a bit peculiar. This forces each bar to animate starting from the top, instead of the bottom.
The jQuery
function fluctuate(bar) {
var hgt = Math.random() * 10;
hgt += 1;
var t = hgt * 30;
bar.animate({
height: hgt
}, t, function() {
fluctuate($(this));
});
}
$(".bar").each(function(i) {
fluctuate($(this));
});
What this does, is to create a random number which will be used to randomly determine the height of each equalizer bar each time we loop through the function.
We then use the .animate() method of jQuery to begin animating the height of each element randomly. Pretty easy, right?
Let’s delve into this code a bit more:
var hgt = Math.random() * 10; hgt += 1;
Creates a random number of 0 to 10. This will be used as the new height of each element, each time the function loops through itself. If we need a taller, or shorter bar, we can change the maximum height by simply adjusting the “10″ value after Math.random().
var t = hgt * 30;
Gets the current height value and multiplies it by a number. This is a little trick to keep the speed with which each bar fluctuates random. If you want something faster or slower, simply adjust that number.
bar.animate({
height: hgt
}, t, function() {
fluctuate($(this));
});
Here we animate the height of our bar, in the random time of t, and then we call the same function again so it loops through itself over and over again.
$(".bar").each(function(i) {
fluctuate($(this));
});
Finally, we iterate this function over every single .bar element.
And there we have it, our own custom jQuery and CSS equalizer! Feel free to use it on your own website if you need to.
MicroJS
June 28th, 2011 - Frontend, Javascript, Utilities, Various Tools - No Comments

What is Microjs.com? Imagine you need a certain JavaScript functionality on your website or app, chances are that someone has already implemented it in an easy to work with framework.
Microjs.com is a nice website that helps you find the suitable JavaScript micro-framework for your needs. Quite useful!
Microjs.com helps you discover the most compact-but-powerful microframeworks, and makes it easy for you to pick one that’ll work for you.
SpriteCow
June 22nd, 2011 - CSS, Frontend - No Comments
![]()
Sprite Cow helps you get the background-position, width and height of sprites within a spritesheet as a nice bit of copyable CSS. How useful is that?
CSS3 animations and their jQuery equivalents
June 18th, 2011 - CSS, Frontend, jQuery - No Comments

A really nice comparison chart with demos can be found over at marcofolio.net. The chart provides a small set of animations that we can create using pure CSS3 (webkit browsers only at the moment) and their equivalents using jQuery.
pdf.js: Rendering PDF with HTML5 and JavaScript
June 17th, 2011 - Frontend, HTML5, Javascript - No Comments

pdf.js is a technology demonstrator prototype to explore whether the HTML5 platform is complete enough to faithfully and efficiently render the ISO 32000-1:2008 Portable Document Format (PDF) without native code assistance.


