Forum Moderators: open
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Antonio Borrillo Photography - Gloom</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="en">
<meta name="description" content="Digital photography">
<meta name="keywords" content="Photography,Digital Photography,Antonio Borrillo,Antonio Borrillo Photography,Gloom,Faith,Light">
<meta name="author" content="Antonio Borrillo">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="stylesheets/containers.css">
<link rel="stylesheet" type="text/css" href="stylesheets/styles.css">
<link rel="stylesheet" type="text/css" href="stylesheets/sprite.css">
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="stylesheets/ie6_and_below.css">
<![endif]-->
[b]<script type="text/javascript">
$(function(){
$(".run_sequence_button").click(function(){
var image = $(".thumb_container").css("background-image");
alert( 'width is: ' + current_height );
var current_width = $("#"+image).width();
var current_height = $("#"+image).height();
console.log(current_height);
});
});
</script>
[/b]
</head>
<body>
<div class="outer_wrapper">
<div class="inner_wrap">
<div class="banner">
<div class="heading_1">
<h1>Antonio Borrillo Photography</h1>
</div><!-- END OF heading_1-->
</div><!-- END OF banner -->
<div class="navigation">
<ul>
<li><a href="home.htm">Home</a></li>
<li><a href="gallery.htm">Gallery</a></li>
<li><a href="portfolio.htm">Portfolio</a></li>
<li><a href="bio.htm">Bio</a></li>
<li><a href="contact.htm">Contact</a></li>
</ul>
</div><!--navigation ENDS -->
<div class="clear"><!-- EMPTY DIV TO CLEAR THE FLOAT-->
</div><!-- END OF EMPTY DIV TO CLEAR THE FLOAT-->
<div class="page_heading">
<h2>Rewind</h2>
</div><!-- END OF page_heading -->
<div class="boxes_wrapper">
<div class="thumb_container">
</div><!-- END OF boxes_wrapper-->
[b]<input type = "button" value = "Run sequence" class = "run_sequence_button">[/b]
<div class="footer">
<p class="footer_paragraph">All photos and content © 2011 Antonio Borrillo. Please read the <a href="terms_and_conditions.htm">terms and conditions here.</a>
</p>
</div> <!-- END OF footer -->
</div><!-- END OF boxes_wrapper -->
</div> <!-- END OF content_wrapper-->
</div><!-- END OF outer_wrapper-->
</body>
</html>
@charset "utf-8";
/* CSS Document */
.thumb_container
{
height:399px;
width:602px;
display:block;
background: url('../images/sprite.jpg') no-repeat;
overflow:hidden;
}
/* to test coordinates work fine */
/*.thumb_container:hover
{
background-position: 0px -399px;
}*/
.run_sequence_button
{
background: url('../images/sprite_button.jpg') no-repeat;
}
var current_height = $("#"+image).height();
and test the value with "console.log(current_height)" I get a value of null. WHy is that? why can't I get the height of my picture? I didn't continue with the script because I got stuck here, any suggestion? I don't necessarily want the code because I would like to try to build the whole script myself, but I am really stuck here, so any help will be greatly appreciated! background: url('../images/sprite.jpg') no-repeat 0 0;
<script type="text/javascript">
$(function(){$(".run_sequence_button").click(function(){
var image = $(".thumb_container").css("background-image"); //that's to copy the image into a variable and make it accessible to the script
$("#" + image).css("backgroundPosition", 0px -399px);//this was supposed to get the background-position changed, but firebug returns an error message which says:"
missing ) after argument list $("#"+image).css("backgroundPosition", 0px -399px); "
...
$("#"+image).css("backgroundPosition", 0px 0px);. Does that sound reasonable at all? I notice that you have not specified an initial background position in the css, this should be:, yep amended it, although it was working even before, what's the advantage of setting the initial position?
background: url('../images/sprite.jpg') no-repeat 0 0;
I guess it is worth pointing out that you seem to have some issues with your divs too (you have two closing divs for "END OF boxes_wrapper")yep sorry the first was meant to be
<!-- END OF thumb_container--> thanks for letting me know : - )
$(".run_sequence_button").click(function(){so thatI store the value before the run sequence button is clicked on. But the value of the background image are 2, width and height so how do I store just the height of the image which is what I need?I thought of using
.css('height')but I need to get the values before the button is clicked so I rewrote the script a little $(function(){
var image = $(".thumb_container").css("background-image");
var height = $("#" + image).css("height");
$(".run_sequence_button").click(function(){
/* console.log(image);*/
$("#" + image).css("backgroundPosition", "0px -399px");
});
}); <script type="text/javascript">
$(function(){
$(".run_sequence_button").click(function(){
/*console.log(image);*/
var image_change = $(".thumb_container").css("backgroundPosition", "0px -399px");
});
});
</script>
var image_position_x = 0;
var image_position_y = -399;
var image_change = $(".thumb_container").css("backgroundPosition", "0px -399px"); can I replace -399px with image_position_y for the sake of argument?
<script type="text/javascript">
$(function(){
$(".run_sequence_button").click(function(){
/*console.log(image);*/
var image_position_x = 0;
var image_position_y= 399;
while(image_position_y <= 5586 )
{
function change_pix()
{
var image_change = $(".thumb_container").css("backgroundPosition", "0px -" + image_position_y + "px");
image_position_y++;
}
setTimeout(change_pix(),3000);
}
});
});
</script>
var image_change = $(".thumb_container").css("backgroundPosition", "0px -" + image_position_y + "px"); var aa=0;
var t;
var positions;
var bb;
var q=0;
function runSeq(){
if(q==1){
return;
}
else
{
positions = ("0 "+aa+"px");
bb=document.getElementById("thumb_container");
bb.style.backgroundPosition = positions;
aa=aa+399;
if(aa > 5586){aa=0;}
t=setTimeout("runSeq()",3000);
}
}; <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Antonio Borrillo Photography - Gloom</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="en">
<meta name="description" content="Digital photography">
<meta name="keywords" content="Photography,Digital Photography,Antonio Borrillo,Antonio Borrillo Photography,Gloom,Faith,Light">
<meta name="author" content="Antonio Borrillo">
<link rel="stylesheet" type="text/css" href="stylesheets/containers.css">
<link rel="stylesheet" type="text/css" href="stylesheets/styles.css">
<link rel="stylesheet" type="text/css" href="stylesheets/sprite.css">
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="stylesheets/ie6_and_below.css">
<![endif]-->
</head>
<body>
<div class="outer_wrapper">
<div class="inner_wrap">
<div class="banner">
<div class="heading_1">
<h1>Antonio Borrillo Photography</h1>
</div><!-- END OF heading_1-->
</div><!-- END OF banner -->
<div class="navigation">
<ul>
<li><a href="home.htm">Home</a></li>
<li><a href="gallery.htm">Gallery</a></li>
<li><a href="portfolio.htm">Portfolio</a></li>
<li><a href="bio.htm">Bio</a></li>
<li><a href="contact.htm">Contact</a></li>
</ul>
</div><!--navigation ENDS -->
<div class="clear"></div>
<div class="page_heading">
<h2>Rewind</h2>
</div><!-- END OF page_heading -->
<div class="boxes_wrapper">
<div class="thumb_container"></div>
<input type = "button" value = "Run sequence" id="run_sequence_button">
<div class="footer">
<p class="footer_paragraph">All photos and content © 2011 Antonio Borrillo. Please read the <a href="terms_and_conditions.htm">terms and conditions here.</a></p>
</div> <!-- END OF footer -->
</div><!-- END OF boxes_wrapper -->
</div> <!-- END OF inner_wrap-->
</div><!-- END OF outer_wrapper-->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="js.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#run_sequence_button").toggle(
function(){q=0;runSeq();},
function(){q=1;runSeq();}
);
});
</script>
</body>
</html>
<script type="text/javascript">
$(function(){
$(".run_sequence_button").click(function(){
var image_position_y = 399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},0);
});
});
</script>
var image_position_y = 399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},0); into another function so that I can easily call it with the setTimeout() method. So I have enclosed them in another function and came up with this:
<script type="text/javascript">
$(function(){
$(".run_sequence_button").click(function(){
function changeSeq()
{
var image_position_y = 399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},0);
.click(function(){
<script type="text/javascript">
$(function(){
$(".run_sequence_button").click(function(){
function changeSeq()
{
var image_position_y = 399;
var t;
if(image_position_y <= 5586)
{
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},0);
image_position_y+=399;
t = setTimeout("changeSeq()", 1000);
}
else
{
image_position_y = 0;
t = setTimeout("changeSeq()", 1000);
}
}
});
});
</script>
<script type="text/javascript">
$(function(){
$(".run_sequence_button").click(function(){
var image_position_y = 399;
function changeSeq()
{
var t;
if(image_position_y <= 5586)
{
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},0);
image_position_y+=399;
t = setTimeout("changeSeq()", 1000);
}
else
{
image_position_y = 0;
t = setTimeout("changeSeq()", 1000);
}
}
});
});
</script>
<script type="text/javascript">
$(function(){
$(".run_sequence_button").click(function(){
var image_position_y = 399;
/*function changeSeq()
{ */
var t;
if(image_position_y <= 5586)
{
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},0);
image_position_y+=399;
/*t = setTimeout("changeSeq()", 1000); */
}
else
{
image_position_y = 0;
/*t = setTimeout("changeSeq()", 1000); */
}
/*} */
});
});
</script>
it still doesn't work as it should but at least it changes one picture and moves to the second one.
COuld it be because I am not allowed to have a function following [quote]click(function(){[/quote] or something like that?
<script type="text/javascript">
$(function(){
$(".run_sequence_button").click(function(){
var image_position_y = 399;
/*function changeSeq()
{ */
var t;
if(image_position_y <= 5585)
{
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
image_position_y+=399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
image_position_y+=399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
image_position_y+=399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
image_position_y+=399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
image_position_y+=399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
image_position_y+=399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
image_position_y+=399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
image_position_y+=399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
image_position_y+=399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
image_position_y+=399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
image_position_y+=399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
image_position_y+=399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
image_position_y-=399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
image_position_y-=399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
image_position_y-=399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
image_position_y-=399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
image_position_y-=399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
image_position_y-=399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
image_position_y-=399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
image_position_y-=399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
image_position_y-=399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
image_position_y-=399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
image_position_y-=399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
image_position_y-=399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
image_position_y-=399;
$(".thumb_container").animate({backgroundPosition: "0px -" + image_position_y + "px"},80);
/*t = setTimeout("changeSeq()", 1000); */
}
else
{
image_position_y = 0;
/*t = setTimeout("changeSeq()", 1000); */
}
/*} */
});
});
<script type="text/javascript">
$(function(){
$(".run_sequence_button").click(function(){
var image_position_y = 391;
while(image_position_y < 5474)
{
$(".thumb_container_rewind").animate({backgroundPosition: "0px -" + image_position_y + "px"},100);
image_position_y+=391;
}
image_position_y-=391;
$(".thumb_container_rewind").animate({backgroundPosition: "0px -" + image_position_y + "px"},100);
image_position_y-=391;
$(".thumb_container_rewind").animate({backgroundPosition: "0px -" + image_position_y + "px"},100);
image_position_y-=391;
$(".thumb_container_rewind").animate({backgroundPosition: "0px -" + image_position_y + "px"},100);
image_position_y-=391;
$(".thumb_container_rewind").animate({backgroundPosition: "0px -" + image_position_y + "px"},100);
image_position_y-=391;
$(".thumb_container_rewind").animate({backgroundPosition: "0px -" + image_position_y + "px"},100);
image_position_y-=391;
$(".thumb_container_rewind").animate({backgroundPosition: "0px -" + image_position_y + "px"},100);
image_position_y-=391;
$(".thumb_container_rewind").animate({backgroundPosition: "0px -" + image_position_y + "px"},100);
image_position_y-=391;
$(".thumb_container_rewind").animate({backgroundPosition: "0px -" + image_position_y + "px"},100);
image_position_y-=391;
$(".thumb_container_rewind").animate({backgroundPosition: "0px -" + image_position_y + "px"},100);
image_position_y-=391;
$(".thumb_container_rewind").animate({backgroundPosition: "0px -" + image_position_y + "px"},100);
image_position_y-=391;
$(".thumb_container_rewind").animate({backgroundPosition: "0px -" + image_position_y + "px"},100);
image_position_y-=391;
$(".thumb_container_rewind").animate({backgroundPosition: "0px -" + image_position_y + "px"},100);
image_position_y-=391;
$(".thumb_container_rewind").animate({backgroundPosition: "0px -" + image_position_y + "px"},100);
image_position_y-=391;
$(".thumb_container_rewind").animate({backgroundPosition: "0px -" + image_position_y + "px"},100);
});
});
</script>
@charset "utf-8";
/* CSS Document */
.thumb_container_rewind
{
height:399px;
width:602px;
display:block;
background: url('../images/sprite.jpg') no-repeat 0 0;
overflow:hidden;
margin: 0 auto;
}
/* to test coordinates work fine */
/*.thumb_container:hover
{
background-position: 0px -399px;
} */
.run_sequence_button
{
background: url('../images/sprite_button.jpg') no-repeat;
}