Feed on
Posts
Comments

jQuery Panel Gallery Plugin 1.2

Note: The latest version of the Panel Gallery is available here.

I’m happy to announce the release of version 1.2. This version adds the ability to pause the transitions simply by placing your mouse over the image as well as specify an amount of overlap in terms of the time of the section transitions.

The best part of this plugin is that not one image needs to be sliced or edited to work with it. Next, you can choose the direction in which the transition occurs from left to right, right to left, top to bottom, or bottom to top – now for each image individually. You can set the initial delay before the transitions begin, set the transitions to loop or stop after the last image, set the time it takes for each panel to appear, and set the delay between the images. Phew.

Download

Download jquery.panelgallery-1_2.js

What’s So Great About this Plugin?

  • No slicing or editing of the images is needed
  • It’s just 8 KB
  • Each image can have its own fade direction
  • The gallery can be set to pause on mouseover (new)
  • Section transition timing can be set to overlap (new)
  • Easily configurable
  • Reusable on multiple containers

How to Use

First, all of your images should be the same size and wrapped in a containing element
(I recommend a div) which must have an ID. Any images will work, however transparent images aren’t recommended. Finally, your container element should be positioned (e.g. relative, absolute, etc.). The container needs to be positioned otherwise the images within it won’t end up in the right spot on your page.

<div id="container" style="position:relative">
	<img src="image1.jpg" alt="image 1" width="500" height="250" />
	<img src="image2.jpg" alt="image 2" width="500" height="250" />
	<img src="image3.jpg" alt="image 3" width="500" height="250" />
	.
	.
	.
</div>

All images *MUST* have the width and height declared otherwise the plugin won’t
work in Safari, Chrome, and any other webkit-based browsers. Also, all images should
be the same size. You can mix various image formats like Gif, Jpg, and Png, however
transparent images aren’t recommended.

To use the plugin you’ll need to have a copy of jQuery, or point to jquery on Google, and the plugin. Place the files on your site and link to them:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="jquery.panelgallery-1_1.js"></script>
<script type="text/javascript">
$(function(){
	$('#container').panelGallery();
});
</script>

Finally, while you don’t have to specify any directions for the fade (the default direction is left to right), you can give each image it’s own direction. To do this, add the name attribute to the image and specify either (lr, rl, tb, or bt). For example:

<img src="image2.jpg" alt="image 2" name="bt" width="500" height="250" />

That’s it! You can apply the panel gallery to any number of elements on a page.

Options

The following options are configurable:

  • sections – the number of panels to divine each image into (default: 3)
  • imageTransitionDelay – the time (in milliseconds) to pause between a
    completed image and the next image (default: 3000)
  • startDelay – the time (in milliseconds) to pause before beginning the first transition (default: 2000)
  • sectionTransitionDelay – the time (in milliseconds) to pause between each section of an image (default: 700)
  • overlap – the percentage of the sectionTransitionDelay option a section should wait before beginning (0 to 1). For example, if the sectionTransitionDelay is 1000 milliseconds and the overlap is set to .75, then at 750 milliseconds the next section transitions will begin. If you want a section to fully complete before the next section begins, set this to 1. (default: .75)
  • enablePause – whether or not to pause the animations when the mouse is placed over an image (default 1).
  • repeat – whether to endlessly repeat the series of images (default: true)
  • direction – the default direction of the transitions: “lr” (left to right), “rl” (right to left), “tb” (top to bottom), and “bt” (bottom to top) (default: “lr”)

Options are added when calling the script:

$('#container').panelGallery({
	sections:5,
	imageTransitionDelay :3000,
	startDelay:5000,
	sectionTransitionDelay : 700,
	repeat:false,
	direction:"tb"
});

Enjoy!

Demos

I’m working on a complete redesign of a site that’s been unchanged for about six years now and among other things, jQuery is being used in the project. I was tinkering with the contact form on this site and was thinking of the bazillions of forms I’ve seen on the web, and how when it comes to forms, contact forms are usually the most basic (although that’s not always the case). Fortunately for me, it is for this form. All that’s needed here is the visitor’s name, email and their comment (all required). Plus a CAPTCHA but that’s not going to change for the redesign. So I was thinking, how could I make this form a) functional (i.e. easy to use) and b) unique? Since this form is pretty basic there wasn’t a whole lot of room to create something that would be useful as well as interesting.

One thing I like to see in forms in general is default text that disappears when a field is clicked on. This tells the visitor what type of input is expected without getting in their way. The most basic JavaScript code would do this with a call to the onfocus event which would clear out the contents of the field. Nothing new. Better code would replace the default text if the visitor leaves the field (onblur) without entering anything. So I set my sights on coming up with something different to accomplish the same effect. Here’s the result (note that the email field has an easing effect applied to it):

As you can see, the default text here smoothly animates out of view once the field is focused on (via keyboard or mouse). Turn JavaScript off and the form works perfectly; however the effect no longer exists, so it also degrades without a problem. Note that I’m not entering a textual default value for the various fields and then deleting the text with jQuery because if the visitor has JavaScript disabled (both of you) then they would have to manually delete the default text, which is more annoying then helpful.

When the user leaves a field, the default text doesn’t return if they have entered something. However if it’s blank, then the default text slides on back in. Unobtrusive, eye-catching, and unique.

All of this is accomplished by manipulating the background image of each text field. jQuery 1.3.2 can animate the background image of an element horizontally (on the x axis) but not vertically. A nice plugin by Alexander Farkas can handle this in case you want to change the effect to look like this (here the comments field has a different easing effect applied to it):

When we focus on a field we slide the background image out of view, and when we leave the field we check the length to see if it is empty in which case the image needs to be moved back to its original position. The typical JavaScript technique that creates or deletes a text field’s default text usually also needs to check to see if the current value of the text field matches the default text since you don’t want whatever is in the text field to disappear every time the field gets focus. Imagine if you entered your name in a field, realized you misspelled it, then clicked back to correct it only to have the whole thing disappear. We don’t have to deal with that scenario here at all since we only check the length of the text in the text box on the onblur event and don’t care about what was entered as long as something was entered. I’ll leave data validation for PHP on the server side for this form. Come to think of it, this method could probably be extended to highlight required fields and perform some basic error checking.

WordPress, the web’s best blogging tool, holds WordCamps which are “informal, community-organized events that are put together by WordPress users like you. Everyone from casual users to core developers participate, share ideas, and get to know each other.”

I’ve been using WordPress casually for a couple of years now and recently saw a blog posting on their site announcing that they were holding a contest to design the logo for the next WordCamp in New York City. Being from New Jersey I couldn’t resist, so I put together a submission and I lost! Well sort of. In the end I, and four other WordPress lovers came up with very similar subway sign ideas that ended up garnering the most overall votes. The judges were so taken with these submission that they declared all four of us winners. Our designs will be used on a variety of materials to market the event.

See http://2009.newyork.wordcamp.org/2009/09/08/logo-contest-winners/ for more.

The design I submitted was:

Technology Importanceometer

Communicating in today’s busy, web-centric world gives people more choices than ever in how they can communicate with each other. Use the scale below to determine how important you are to someone communicating with you. Methods are listed in order from most to least important.

  1. Face to face – the most important way to communicate. Nothing says you’re important more than a face to face meeting.
  2. Phone call – When face to face communication isn’t possible due to distance or time, the next best option is a phone call. A plane ticket was out of the question but long distance fees weren’t.
  3. Email (sent directly to you) – Sometime cost matters. When you don’t justify the cost of a stamp or waiting for the post office to deliver a message would just take too long, there’s email.
  4. Letter – Taking the time to hand write a message and cough up 44 cents for a stamp shows that someone values you, although the fact that it will take several days for you to receive it slightly reduces your importance.
  5. Instant message – I need to tell you something, however it’s not important enough for me to fire up my email program nor is it important enough for me to spell check what I’m writing, so I’ll send you an instant message instead. I also hope you weren’t expecting an attachment.
  6. Text message – I’m holding in my hand a cell phone, a device which is capable of the number two most important form of communication, however I decided against calling and instead chose to send you a short text message. My thumbs are willing to hunt and peck out some message that won’t be spell checked nor grammar checked, and will probably contain idiot shorthand like “ur” and “cul8r”, however they aren’t willing to dial your phone number so that I can use my voice to actually talk to you. Alexander Graham Bell spins three times in his grave for every text message you send.
  7. Video/Teleconference – I was required to tell a bunch of people something all at the same time. No one merited a face to face meeting and calling each person individually would’ve been waaaay too much work.
  8. Email (cc’d to you) – This message isn’t even really for you but I thought I should cover my ass and let you know what I was telling someone else. Read this if you’re bored.
  9. Facebook – When you want to share information with a bunch of people you may or may not know, and don’t care about enough to tell directly, write it on Facebook. Sharing information by using Facebook is like sending out a holiday newsletter detailing what you’ve been up to all year – only more often and with less importance.
  10. Twitter – The least important, and most narcissistic, method of communicating, Twitter says it all. As long as it’s less than 140 characters. Tweets have all the value of a fortune cookie message and are roughly equivalent to writing something on the wall of a bathroom stall. You don’t really care who reads it and almost no one gives a damn.

This is one of those things that kinda bugged me for a while but was so low on my listof things to care about I just never bothered to look deeper into it. I’m talking about the mysterious, seemingly random appearance of the letter J in some emails and and web pages. For those of you that may not know what in the world I’m talking about, this image should explain it:

j

Now I don’t think of myself as narcissistic, but I thought wow how nice, they’ve gone and personalized this page for me by putting my initial on the page. In a weird spot. Repeatedly. Without any way of knowing that my first name is Jason. Ok  so being that this example is from my daughter’s (horribly ugly and poorly coded) school system web site, I knew that what I saw could only be the result of some ugly error. But the problem was, I’ve seen this mysterious J popup in various emails and other web pages, so I decided to track down where it was coming from.

After a bit of searching I found a three year old post on the Microsoft blog that turned the lightbulb on over my head. Turns out that the J’s that I was seeing in Firefox and Safari (IE and Chrome didn’t do it) were supposed to be a smiley face in the Wingdings fonts. Low and behold I went back to my daughter’s school site, checked out the source code, and there it was, an inline CSS rule (blech) specifying the Windings font and the letter J (e.g. font-family:Wingdings). Now like 99.999%  of people using Windows, I have the Windings font installed, yet Firefox didn’t want to display it. Go figure.

So the lesson learned from this is a) the next time you see an errant J on the web or in an email, try mentally substituting a smiley face, b) don’t use the Wingdings font in your style sheets because some browsers will ignore it and c) if you need to insert a text smiley face in an email or web page, use the old standby of :) or :-) instead (or maybe even unicode 263a). Now I can sleep at night.

« Newer Posts - Older Posts »