Can’t keep your erection to have intercourse? You can solve this issue by taking viagra online with ease. No need to face such embarrassing moments again. cialis online also works similarly like Viagra. You casino online can get these medications by browsing casino online websites.

jQuery

jQuery 1.5 released!

Posted in jQuery on February 1st, 2011 by Mike – Be the first to comment

As everybody who knows me knows… I'm a huge fan of jQuery. So needless to say, the next major release of jQuery (1.5) has me extremely excited!

We are told that the largest charge to jQuery with this version is AJAX. It has been completely rewritten in jQuery. Instead of returning a regular XMLHttpRequest object, jQuery.ajax(…) now returns a jXHR object. This allows you to perform previously impossible tasks like aborting JSONP requests, according to the jQuery blog.

jQuery 1.5 also introduces deferred objects. This is a chainable utility object that can register multiple callbacks into callback queues, invoke callback queues, and relay the success or failure state of any synchronous or asynchronous function.

And finally, one of the most exciting changes in jQuery 1.5 is the massive performance increase in traversal functionality. Calls to .children(), .next() and .prev() have been dramatically sped up.

This was just a quick overview of the changes jQuery 1.5, and more importantly a notification that you should go get jQuery 1.5 immediately and start experiencing the changes for yourselves! Full information on the jQuery 1.5 release can be found at: http://blog.jquery.com/2011/01/31/jquery-15-released/

Thanks for reading!

How to Create a Throbbing/Pulsing Image Effect With jQuery

Posted in jQuery on January 27th, 2011 by Mike – 3 Comments

I received a request from a client of mine who sought my help after his other developer was unable to perform a specific task using jQuery, and they didn't want to revert to Flash. As you probably guessed, he wanted a throbbing or pulsing image effect. An image (several, actually) were to "fade" in & out partially, to give the desired illusion when hovering over the image with your mouse. Not only that, but the effect needed to continue repeating as long as the mouse was hovering over the image.

I've never built such an effect before, and was unable to really locate any help with it via Google and so after a few minutes of planning and experimenting, my appreciation for jQuery's simplicity and power was once again renewed. Here, I'll explain how to achieve the effect and show a demo of it since nobody else has documented it that I could find.

To demonstrate the effect I'm going to show you how to reproduce, take your mouse and hover over this image:

Demo Headshot for throbbling / pulsing jQuery effect

Neat? I thought it was. And thanks to jQuery, the effect can be had with MINIMAL work. In fact, I'm going to provide the code for you copy/paste-type folks, and then explain how it works.

 

// #############################################
(function($) {
	$(document).ready(function() {
		window.pulse_image = null;
		window.pulse_continue_loop = false;
		
		$('.pulse_image').mouseover(function() {
			// User is hovering over the image.
			window.pulse_continue_loop = true;
			window.pulse_image = $(this);
			
			PulseAnimation(); // start the loop		
		}).mouseout(function() {
			window.pulse_continue_loop = false;
			window.pulse_image.stop();
			window.pulse_image.css('opacity',1);
		});
	});
})(jQuery);

// #############################################
function PulseAnimation()
{
	var minOpacity = .33;
	var fadeOutDuration = 650;
	var fadeInDuration = 650;
	
	window.pulse_image.animate({
		opacity: minOpacity
	}, fadeOutDuration, function() {
		window.pulse_image.animate({
			opacity: 1
		}, fadeInDuration, function() {
			if(window.pulse_continue_loop) {
				PulseAnimation();
			}
		})
	});
}
  1. Copy and paste the above code into a file (I'm using /js/pulse_image.js).
  2. Make any changes you'd like to the minOpacity, fadeOutDuration, fadeInDuration (duration is specified in milliseconds; 1000ms = 1 second)
  3. Link to the javascript file within your web-page. I'm assuming you've already linked to jQuery.
  4. Give your image or images that you want to have this effect a class of pulse_image.
  5. Enjoy!

For those who are still reading, I'm going to assume you want to know how it works. It's actually quite simple.

We set 2 global variables called pulse_image and pulse_continue_loop.

window.pulse_image is a jQuery object for the CURRENT image that is being hovered, or previous image that was being hovered.

window.pulse_continue_loop tells us whether we want to continue the pulse effect animation or not. This is a boolean flag.

When the DOM is ready, we initialize those two global variables and then create our event handlers. When any element with a class of pulse_image has its mouseover event fired, we set our pulse_continue_loop flag to TRUE, because we do want a constant pulsing effect. We also assign the pulse_image variable a jQuery object that is for the current image being hovered. Finally, we start the animation by calling PulseAnimation().

Next, we need to handle when the image is no longer being hovered. When this event fires, we set pulse_continue_loop to FALSE, because we're done with the animation… the mouse is no longer hovering. In addition, we want the current animation to stop, so we call pulse_image.stop(). Since we may have stopped that animation mid-fade, we set the image's opacity back to 100% (1).

So now we've directed what should happen, when… but still need the actual WORK done. This is where the PulseAnimation() function we called earlier comes in.

Here, we have 3 local variables we can set to configure the dynamics of our animation. Those are pretty self-explanatory and the defaults work very well. Experiment as you wish.

We take our image, pulse_image, and create an animation. The only effect we're doing is setting the opacity to minOpacity which is defined above. We specify our fadeOutDuration, and then our callback function. Within our callback function, we're starting a NEW animation, which sets the opacity back to 100% (1), over a period of time specified by fadeInDuration, which then has its own callback.

Within the second animation's callback, we check if we need to continue looping or not (via pulse_continue_loop global variable). If true, we call PulseAnimation() which starts the initial animation over again, and the cycle repeats. This is our exit strategy which is vital or else we would be stuck in an infinite loop. pulse_continue_loop gets set to FALSE whenever the mouse stops hovering over the image, effectively stopping our loop when the animation is no longer needed.

So there we have it. In 39 lines of code, we achieved a throbbing or pulsing effect with jQuery. We can make any number of images have this animation, and in fact it's not limited to only images!

Mouse Over Me!

All that's needed to be done is adding a simple class to any element that you want to have the effect. It doesn't get much easier than that. Thanks, jQuery!

jQuery — Is It Really Worth Using?

Posted in jQuery on January 25th, 2011 by Mike – Be the first to comment

Ah, I've been asked many times if people should stick with native Javascript, or use a Javascript library like jQuery.

Short Answer: Use jQuery.

Longer Answer:

Why? jQuery is by far the best JS library I've used. It doesn't just take the tediousness out of writing javascript, but it makes it downright FUN. Using jQuery, you're able to write in 1 line of code what would take you 10-15 lines of code using native javascript!

It's very lightweight, fast and has a minimal footprint. It weighs in at about 26KB minified & gzipped.

jQuery gives you the ability to execute code when the DOM is loaded, not just when the window entirely is loaded (meaning all graphics & other external resources). Not only that, but you can specify in multiple areas what code to execute when the DOM is loaded.

jQuery supports CSS 1-3  selectors which dramatically reduces the amount of code you need to write to get your work done. It handles animations, AJAX calls, DOM manipulation, and more with sheer elegance and beauty. Extending jQuery is where it really shines. You can find a plugin for nearly anything you'll need.

If you've ever dealt with native Javascript for anything beyond the most elementary of tasks, you'll probably have discovered that cross-browser compatibility issues sneak up on you in a hurry. jQuery takes care of this. It is fully cross-browser compatible, and is frequently updated to ensure that it remains cross-browser compatible, fast, lightweight and bug-free. This is one of jQuery's most powerful assets.

Still not convinced? Here are just a handful of BIG NAMES that use jQuery:

  • Google
  • Dell
  • Bank of America
  • digg
  • Netflix
  • Mozilla
  • WordPress
  • Drupal

I encourage you to spend a few hours playing with jQuery and discovering first-hand just how powerful it is. The learning curve is minimal, and the benefits are tremendous. jQuery is THE javascript library to use. You'll spend more time getting things done, and less time coding.

As always, I'd love to hear what you think. Leave me a comment with your thoughts!