Template:CSU Template 1 top
From 2012.igem.org
(Difference between revisions)
Line 266: | Line 266: | ||
</style> | </style> | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
//newOpac: sets new opacity | //newOpac: sets new opacity | ||
Line 293: | Line 276: | ||
function fade(curElemID,isFading) { | function fade(curElemID,isFading) { | ||
+ | //length that each slide shows before fade (in milliseconds) | ||
var slideStayTime = 2000; | var slideStayTime = 2000; | ||
+ | |||
+ | //length of fade (milliseconds) | ||
var fadeTime = 1000; | var fadeTime = 1000; | ||
- | var | + | |
+ | //number of fade loops: > means smoother, more CPU-intensive transition | ||
+ | var numFadeLoops = 10; | ||
+ | |||
+ | //In order for fade to work correctly, opacity must be rounded to | ||
+ | //the appropriate number of decimal places. roundTo defines this. | ||
+ | //For numFadeLoops < 20, roundTo = 1 will suffice. roundNum is the | ||
+ | //functional form. | ||
var roundTo = 1; | var roundTo = 1; | ||
var roundNum = Math.pow(10, roundTo); | var roundNum = Math.pow(10, roundTo); | ||
Line 328: | Line 321: | ||
//Sets new opacity and reruns the function | //Sets new opacity and reruns the function | ||
- | var newOpac = (Math.round(roundNum * (parseFloat(curElem.style.opacity) - (1/ | + | var newOpac = (Math.round(roundNum * (parseFloat(curElem.style.opacity) - (1/numFadeLoops)))) / roundNum; |
curElem.style.opacity = newOpac; | curElem.style.opacity = newOpac; | ||
- | setTimeout('fade(' + curElemID + ')', (fadeTime/ | + | setTimeout('fade(' + curElemID + ')', (fadeTime/numFadeLoops)); |
//Current slide has faded completely | //Current slide has faded completely |
Revision as of 16:56, 25 July 2012