New jQuery Plugin – ImageSwitch, amazing effect with simple code


March 13, 2009
Feedback's a good way to encourage author even if it's a criticize. It's proved you care about the article. Please, leave a comment to let everyone know what you think about this post.

another tip »

ImageSwitch

jQuery Plugin – ImageSwitch

It's a while from the last time I updated my blog. I spend all spare time to make a new jQuery plugin – ImageSwitch and this is one of the most favorite plug-ins. The main point of this plug-in is to make an easy-to-use, simple and fast plug-in to create effect when you switch between images. Minimize the arguments you need to input and still give some beatiful effects. Check out the front page and the examples page of the plug-in for full demonstration.

Why using this

With jQuery, it's so easy to create simple effect such as fade in, move object around, unfortunately when you need to create an effect for image switching, it will require a bit more to create an attractive effect. That isn?t difficult but it isn't simple either and sometimes it's kind of mess your code up.

To change image normally, you could use:

image.src = "new image"

or with jQuery

$(image).attr("src", "new image")

With ImageSwitch, you can change the image with new effect as simple as

$(image).ImageSwitch({NewImage: "new image"})

Developer friendly

All the code is commented to explain itself. The reason is so everyone could read and understand the code edit it to suitable with the situation you want. Sometime you only need just 1 single effect not the whole plug-ins so you could change it to optimize for you situation.

Problems

There is some compatible problems in specific is the Flip effect can't not work properly due to I.E z-index bug. I still can't find a solution. Hope anyone could help me with that T_T.

Hope to get feedback

The plug-in has its own website which?s hosted in my project server. However, I still use this website as the blog for the plug-in. You could give the comment as a way to encourage me in my blog. I hope I could choose some good reviews to put in the plugin front page as well^_^.

As the plugin has just come out, it might have a few (maybe a lot T_T) bugs and errors. I would appreciate if you let me now the error and I will try to fix it as soon as possible.

I also welcome the new effect idea as well. As I myself also planning to make more effects in the future if people like this plug-in.

 

Thank You!

Share
Under Category: jQuery
Article Tags: ,
March 13th, 2009
John

Brilliant Plugin! Very nice!

March 14th, 2009

Hi, thanks, it’s good to know you like it

March 14th, 2009

It looks very nice and the effect is very cool!

March 14th, 2009

Awesome, tagged it for further inspections. :)

However there seems to be a little mistake:

[quote]Name it anything you want. I will name it: [b]TestImg[/b][/quote]
http://www.hieu.co.uk/ImageSwitch/Info.aspx

Then you go on but do not name your img "TestImg":
[quote]
<img src="[b]image1[/b]" />
<a href="#" id="TestTrigger"></a>
[/quote]
Regards,

René

March 14th, 2009

Oop, my bad. Thank you so much to inform me. I fix the errors already :) .

March 15th, 2009

Hi there,

Very cool plugin, added an announcement here:
http://www.opensourcereleasefeed.com/release/show/imageswitch-jquery-plugin

Kind Regards,
Schalk

March 15th, 2009

Thank Schalk, I’m also a fan of your website :) .

March 15th, 2009

@hieuuk – Awesome, thanks so much. Glad to have you on board ;)

March 16th, 2009

Hello,

Please add your site at http://www.sweebs.com. Sweebs.com is a place where other people can find you among the best sites on the internet!
Its just started and we are collecting the best found on the net! We will be delighted to have you in the sweebs listings.

Regards
Kris

March 16th, 2009
HieuUk

@Kris: Added already. Thanks :) . I’m planning to make one of this for my languages as well. I’ll learn a lot from your website.

March 18th, 2009
zarouk

Great plugin !!!
Do you think it will be possible to have an option to "auto-switch" in future release.

It will be great for example to "auto-switch" every 5 seconds.

Best regards,

March 18th, 2009
zarouk

Great plugiin !!!

do you think it will possible to have an option to "auto-switch" in a future release ?

It wil be great for example to "auto-switch" every 5 seconds.

Best regards,

March 18th, 2009
alan

how do I activate the demos?

March 18th, 2009

Hi, all you have to do is click on the effect name (Fade in, Fly in…). And make sure you have Javascript turn on as well.

March 20th, 2009

Great plugin. However if you try to click a trigger to activate the plugin while it is in the middle of doing the animation, it seems to throw off the formatting and move it to absolute position 0,0.
Anyone else have that problem?

March 21st, 2009

Its working thanks a loooot!

April 6th, 2009
Evan

I have found that when I have this trigger on a mouseover of the image I want to fade, it will fade the image twice. I am guessing it is because the first fade I see if the image pre-loading, then the code thinks it is fading the image in.

It works fine if I hover on a link to trigger the fade.

Also, when I mouseoff the image to switch back, it only needs to run once.

Is there a way I could put some sort of stop in so it will only fade the image in once?

April 7th, 2009
admin

@Evan: I think I know the problem, the first image fade, and new image stay on top of it -> JS thought you mouse move out of the image already…
If you check this article, I wrote about apply IS in web dev, check the RSS fade in effect, it could explain how to make it work in this situation:
8 Guides to apply jquery and Imageswitch in web design

June 8th, 2009
aj

thanks for the great effect,

I’d love to use just the fade effect to cycle through a couple of photos, how could you set this up to auto cycle through every 3 seconds?

Thanks

June 9th, 2009

Hi,
This link contain the guide of how to make the script loop automatically, hope it will help :)
http://www.hieu.co.uk/blog/index.php/2009/03/21/8-guides-to-apply-jquery-and-imageswitch-in-web-design/

October 11th, 2009
Toan

Awesome article!
Are you Vietnamese, Hieu?
Nice to meet .

October 11th, 2009

Thank Toan :) .
Yes I’m Vietnamese however I’m currently working in UK :)

April 12th, 2011

couples have is a priority, small recommend three kinds of color han2 ban3 wedges sandals, whether very cute?

April 25th, 2011

When the movie “sex and the city 2″ trailer global distribution, appear even in CCTV news channel, the audience is very friendly to expect to this film clothing modelling division Patricia Field.

June 15th, 2011
Jeroen

Hello, does any one know how to get rid of the black edges around PNG files I had read that you need to put the effect on a div. But the effect takes place in javascript and only uses one div “splashframe”.
Does any one know how to make this example whitout the black edges in internet Explorer 7, en 8? Lets say whit pngiefix or something like that?
Thanks for any help.

*{
padding: 0;
margin: 0;
font-family: verdana, arial;
font-size: 12px;
}

h3{
font-size: 1.3em;
margin: 10px;
}

p{
margin: 10px;
}

a{
text-decoration: none;
text-color: #007BEC;
}

a:hover{
text-decoration: underline;
}

a img{
border: none;
margin: 0 10px 0 0;
}

body{
background: #FFF;
padding: 50px;
}

/* Example style */
.SplashFrame{
width: 497px;
height: 236px;
margin: 0 auto;
padding: 27px 0 0 36px;
}

.SlashEff{
background: url(Images/tryitnow.jpg) no-repeat 0 0;
width: 550px;
height:62px;
margin: 20px auto 0;
padding: 5px 0 0 60px;
}

.SlashEff ul li{
float: left;
list-style-image: none;
list-style-type: none;
width: 100px;
cursor: pointer;
}

.SlashEff ul li:hover{
text-decoration: underline;
}

var ImgIdx = 2;
function PreloadImg(){
$.ImagePreload(“images/slash1.png”);
$.ImagePreload(“images/slash2.png”);
$.ImagePreload(“images/slash3.png”);
$.ImagePreload(“images/slash4.png”);
}
$(document).ready(function(){
PreloadImg();
$(“.SlashEff ul li”).click(function(){
$(“.Slash”).ImageSwitch({Type:$(this).attr(“rel”), NewImage:”images/slash”+ImgIdx+”.png”, speed: 4000 });
ImgIdx++;
if(ImgIdx>4) ImgIdx = 1;
});
});

TRY EFFECTS

Fade in
Fade in
Fade in
Fade in

July 7th, 2011
Muhammad Ali Shan

Really stuck on my way to implement revealing previous image using FLIPIN effect.

I am using FlipOut to move to a NEXT image and want to use FlipIn to move back to PREVIOUS image.

Can anyone help?

Kind Regards

Trackbacks
Leave a Reply