Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-12-2012, 11:03 PM   PM User | #1
Vrutin
New Coder

 
Join Date: Dec 2012
Posts: 10
Thanks: 1
Thanked 0 Times in 0 Posts
Vrutin is an unknown quantity at this point
Thumbs up How to mix jQuery Features and JavaScript ..

Hello, I created this basic slideshow in JavaScript. That can go next, previous, first and last.

Now, its pretty simple and there is no animation.

Could I use jQuery features like fadein and so on in my current script?

Code:
// Slide Show Previous, Next , First & Last

var min = 1;
var last = 5;

var current = min;

function moveSlide(moveMe) {
	if (moveMe == 0) {
		current = min;
	}
	current = current + moveMe;
	if (moveMe == "end") {
		current = last;
	}
	if (current > last) {
		current = min
	} else if (current < min) {
		current = last;
	}
	document.getElementById("img1").src = "images/slide" + current + ".png";
}
Do I need to add the jQuery Lib in this current custom.js file?

Thanks in advance

Last edited by Vrutin; 12-12-2012 at 11:07 PM..
Vrutin is offline   Reply With Quote
Old 12-12-2012, 11:45 PM   PM User | #2
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,584
Thanks: 5
Thanked 864 Times in 841 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Fading is not specific to jQuery, you can create your own fade animation (you just have to kinda reinvent the wheel). Basically you set up an interval (setInterval()) during which you decrease and increase the opacity of the image sequentially. But of course, you could just add jQuery and use that one. After all, jQuery is just JavaScript, too.

Note, however, that with your current set-up you can only fade out and in subsequently, not simultaneously/seamlessly since you’re just changing one image’s source attribute value. You need to fade out the image, change the src value and then fade in again.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 12-12-2012, 11:58 PM   PM User | #3
Vrutin
New Coder

 
Join Date: Dec 2012
Posts: 10
Thanks: 1
Thanked 0 Times in 0 Posts
Vrutin is an unknown quantity at this point
Here's how I am thinking to do this:

When the slider area loads, it fades into first image..

Then every time there is a click on next || previous || first || last..

it fades into that image...

that would create the fade in effect ..

Please correct my understanding if I am thinking wrong.

Thanks
Vrutin is offline   Reply With Quote
Old 12-13-2012, 12:28 AM   PM User | #4
Vrutin
New Coder

 
Join Date: Dec 2012
Posts: 10
Thanks: 1
Thanked 0 Times in 0 Posts
Vrutin is an unknown quantity at this point
I am just playing with the ideas.. However, the following code is not executing.. any reasons why?

Code:
// left is the division where the slideshow resides
$("#left").ready( function() {
	
	$("#1").show("fade", 1000); // 1 is the image ID
	
});
Thanks
Vrutin is offline   Reply With Quote
Old 12-13-2012, 01:04 AM   PM User | #5
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,447
Thanks: 0
Thanked 496 Times in 488 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
Quote:
Originally Posted by VIPStephan View Post
Fading is not specific to jQuery, you can create your own fade animation (you just have to kinda reinvent the wheel).
You don't even need to do that.Just go to http://www.brothercake.com/site/reso...s/transitions/ and grab the transitions JavaScript library from there. It has all sorts of different fades built in.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:30 PM.


Advertisement
Log in to turn off these ads.