PDA

View Full Version : Help wanted on how to achieve a Left to Right page turning effect (Book Flip script)



lasp2005
06-05-2005, 09:26 PM
From: Luiz Antonio S. Pereira

(June, 05)



I am a teacher, with no programming knowledge, Can you help me?


Could you apply the necessary changes to the beneath code to
achieve a LEFT to RIGHT page turning effect.




P.S.: The beneath code is a (full working) short version from the
original code. (The focus here is only the page turning effect.)





<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<!-- saved from url=(0055)http://www.dynamicdrive.com/dynamicindex14/bookflip.htm -->

<HTML>
<HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
</HEAD>

<BODY onload=ImageBook()>


<SCRIPT type=text/javascript>/*(c) Ger Versluis 2003*/


var B_LI;
var B_MI;
var B_RI;
var B_MSz;
var B_Angle=0;
var B_CrImg=6;
var B_Direction=1;
var Book_Speed=15;
var Book_Vertical_Turn=0;
var Book_Image_Width=140;
var Book_Image_Height=225;


Book_Image_Sources=new Array
(
"photo1.jpg","",
"photo2.jpg","",
"photo3.jpg","",
"photo4.jpg",""
);


var B_Pre_Img=new Array(Book_Image_Sources.length);



function ImageBook()
{

if(document.getElementById)
{
for(i=0;i<Book_Image_Sources.length;i+=2)
{
B_Pre_Img[i]=new Image();
B_Pre_Img[i].src=Book_Image_Sources[i]
}


Book_Div=document.getElementById("Book");


B_LI=document.createElement("img");Book_Div.appendChild(B_LI);
B_RI=document.createElement("img");Book_Div.appendChild(B_RI);
B_MI=document.createElement("img");Book_Div.appendChild(B_MI);


B_LI.style.position=B_MI.style.position=B_RI.style.position="absolute";
B_LI.style.zIndex=0; B_MI.style.zIndex=1; B_RI.style.zIndex=0;
B_LI.style.top=(Book_Vertical_Turn?Book_Image_Height+1:0)+"px"; B_MI.style.top=0+"px"; B_RI.style.top=0+"px";
B_LI.style.left=0+"px";
B_MI.style.left=(Book_Vertical_Turn?0:Book_Image_Width+1)+"px";
B_RI.style.left=(Book_Vertical_Turn?0:Book_Image_Width+1)+"px";
B_LI.style.height=B_MI.style.height=B_RI.style.height=Book_Image_Height+"px";
B_LI.style.width=B_MI.style.width=B_RI.style.width=Book_Image_Width+"px";


B_LI.style.borderStyle=B_MI.style.borderStyle=B_RI.style.borderStyle="solid";
B_LI.style.borderWidth=B_MI.style.borderWidth=B_RI.style.borderWidth=1+"px";
B_LI.style.borderColor=B_MI.style.borderColor=B_RI.style.borderColor="gray";


B_LI.src=B_Pre_Img[0].src; B_MI.src=B_Pre_Img[2].src; B_RI.src=B_Pre_Img[4].src;


BookImages()
}

}




function BookImages()
{

B_MSz=Math.abs(Math.round(Math.cos(B_Angle)*Book_Image_Width));
MidOffset=B_Direction?Book_Image_Width+1:Book_Image_Width-B_MSz;
B_MI.style.left=MidOffset+"px";
B_MI.style.width=B_MSz+"px";


B_Angle+=Book_Speed/720*Math.PI;


if(B_Angle>=Math.PI/2&&B_Direction)
{
B_Direction=0;
if(B_CrImg==Book_Image_Sources.length)B_CrImg=0;
B_MI.src=B_Pre_Img[B_CrImg].src;
B_MI.lnk=Book_Image_Sources[B_CrImg+1];
B_CrImg+=2;
}


if(B_Angle>=Math.PI)
{


}

else setTimeout("BookImages()",50)

}


</SCRIPT>


<DIV id=Book style="POSITION: relative"><IMG height=227 src="placeholder.gif" width=144> </DIV>


</BODY>
</HTML>

jscheuer1
07-01-2005, 04:31 AM
http://www.burmees.nl/menu/bookextended.html