Jump to content

repositioning element when browser size changed


sweetysweety

Recommended Posts

hi,i have a website like:http://www.terranartworks.com/testsite/tsv1/i want to do that repositioning red point,when browser size has changed.i mean that think about you clicked one of 3 buttons on bottom.red point comes sliding and position at the middle of button.then you reduce the width of browser.the red point is stays at the first position.but it should reposition according to reduced amount.how can i do this with jquery?

Link to comment
Share on other sites

i don't want reload page.i just want to slide right or left the redpoint as the browser width change.

for example the page loaded and then i click first button on bottom of page.

the red point will comes to the middle of that button.

then i reduce the width of browser.

the red point stays the first position.

but the button is repositioned.

so if the red point stays on first location that it placed,this means that it is not staying on the middle of button.

 

like http://www.terranartworks.com/testsite/tsv1/islerimiz.html

 

 

as you see,i changed browser size and red point stays at the right of second button.i don't want to see this attitude.i want to reposition red point at the middle of second button again.

Edited by sweetysweety
Link to comment
Share on other sites

you mean this:

$(function() {	var offset,center,width,newCenter=3;        		$mainNav1 = $("#point");    $mainNav1.append("<li id='red'></li>");	    var $redPoint = $("#red");    $redPoint        .width($redPoint.width())        .height($redPoint.height())			$("#menuButtons .menuItem a").live({			click:function() {				$(window).resize(function(){				offset=$(this).offset();				width=$(this).width();				center=(offset.left+width/2)-newCenter;				$redPoint.stop().animate({left:center});				 window.setTimeout('location.reload()');				 			});				}			}); });

or this:

$(function() {	var offset,center,width,newCenter=3;        		$mainNav1 = $("#point");    $mainNav1.append("<li id='red'></li>");	    var $redPoint = $("#red");    $redPoint        .width($redPoint.width())        .height($redPoint.height())		$(window).resize(function(){			$("#menuButtons .menuItem a").live({			click:function() {				offset=$(this).offset();				width=$(this).width();				center=(offset.left+width/2)-newCenter;				$redPoint.stop().animate({left:center});				 				}			}); 			window.setTimeout('location.reload()');				 			});});

i try either way but it didn't work.i put location to my path of jquery code but it didn't work too.

i search on the internet and some examples uses function for it.do i have to use function for it?

Link to comment
Share on other sites

This is the code that positions it AFTER click event is triggered

 

offset=$(this).offset(); width=$(this).width(); center=(offset.left+width/2)-newCenter; $redPoint.stop().animate({left:center});

 

BY inserting the click event inside the resize() you are telling it after a resize of browser window is detected, run this code which will WAIT FOR A CLICK EVENT BEFORE DOING ANYTHING, do you really want to do this? think about! use your little grey cells.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...