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 03-08-2013, 11:52 AM   PM User | #1
jarv
Banned

 
Join Date: Mar 2007
Posts: 1,523
Thanks: 116
Thanked 0 Times in 0 Posts
jarv can only hope to improve
Question Animate background image up?

Hi, On my site in my footer I have some social media icons that animate the background up when I hover over.

I would like to do this on my 4 main boxes: Who, work, blog, contact
as you can see, I have attempted it on the first box: "Who are we?"

here is my site:

http://staging.graphitedigital.com/2013/dev/#

Javascript
Code:
jQuery('ul#sections li#who').hover(function() {
				jQuery(this).stop().animate({
					marginTop : '-182px'
				}, {queue:false,duration:600,easing:'easeInOutQuint'});
				}, function(){
					jQuery(this).stop().animate({
					marginTop : '0px'
					}, {queue:false,duration:850});
			});
jarv is offline   Reply With Quote
Old 03-08-2013, 01:52 PM   PM User | #2
harbingerOTV
Senior Coder

 
Join Date: Jan 2005
Location: Memphis, TN
Posts: 1,765
Thanks: 8
Thanked 123 Times in 121 Posts
harbingerOTV will become famous soon enough
You could always leave the simple color swap you have now for default and then use CSS3 for the browsers that like it:
transition: background-position
http://www.impressivewebs.com/demo-f...mated-sprites/

If you want to use jQuery like you are trying to do, you are moving the wrong thing.

Code:
jQuery('ul#sections li#who').hover(function() {
				jQuery(this).stop().animate({
					marginTop : '-182px'
That moves the <li> itself. You want to animate the background-position of the <li> instead.
__________________
Stop making things so hard on yourself.
i is tugbucket :: help raise tugburg :: Whitehaven Kiwanis
harbingerOTV is offline   Reply With Quote
Old 03-08-2013, 02:18 PM   PM User | #3
jarv
Banned

 
Join Date: Mar 2007
Posts: 1,523
Thanks: 116
Thanked 0 Times in 0 Posts
jarv can only hope to improve
ok thanks, I have added <span></span> inside the <li> and targeted that but it's not working?!

Code:
			jQuery('ul#sections li#who a span').hover(function() {
				jQuery(this).stop().animate({
					marginTop : '-182px'
				}, {queue:false,duration:600,easing:'easeInOutQuint'});
				}, function(){
					jQuery(this).stop().animate({
					marginTop : '0px'
					}, {queue:false,duration:850});
			});
jarv is offline   Reply With Quote
Old 03-08-2013, 03:34 PM   PM User | #4
harbingerOTV
Senior Coder

 
Join Date: Jan 2005
Location: Memphis, TN
Posts: 1,765
Thanks: 8
Thanked 123 Times in 121 Posts
harbingerOTV will become famous soon enough
Remove the background from the LI and give it to the SPAN.

Code:
ul#sections li#who a span {
    background: url("../_img/AboutBox_image.png")top left no-repeat;
    position: absolute; 
    width: 100%; 
    height: 100%; 
    top: 0; 
    left: 0;
}
then (untested but close if not) :

Code:
			jQuery('ul#sections li#who a').hover(function() {
				jQuery('span', this).stop().animate({
					top : '-182px'
				}, {queue:false,duration:600,easing:'easeInOutQuint'});
				}, function(){
					jQuery('span', this).stop().animate({
					top : '0px'
					}, {queue:false,duration:850});
			});
__________________
Stop making things so hard on yourself.
i is tugbucket :: help raise tugburg :: Whitehaven Kiwanis
harbingerOTV is offline   Reply With Quote
Old 03-08-2013, 07:28 PM   PM User | #5
jarv
Banned

 
Join Date: Mar 2007
Posts: 1,523
Thanks: 116
Thanked 0 Times in 0 Posts
jarv can only hope to improve
yes close, thanks.
I have got to this stage before:
http://staging.graphitedigital.com/2013/dev/#

it's suppose to be orange underneath though?!
jarv is offline   Reply With Quote
Old 03-10-2013, 07:25 PM   PM User | #6
jarv
Banned

 
Join Date: Mar 2007
Posts: 1,523
Thanks: 116
Thanked 0 Times in 0 Posts
jarv can only hope to improve
can anyone help here please?
jarv 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 11:53 AM.


Advertisement
Log in to turn off these ads.