I'm working on a mini project where I interview people on short GIF animations. I need to let people see the GIF for 10 seconds and with my code, I've realised that the timer is inaccurate.
I've searched around and found the fix in the Sitepoint article by James Edwards. However its in Javascript and I've been trying to combine the JS and Jquery together but with no success at all.
Here
$(function() {
//when showing image
setTimeout(function() {
$("#div2").fadeOut(0);
}, 10000) //edit timer
$('#btnclick').click(function() {
$('#div2').show();
setTimeout(function() {
$("#div2").fadeOut(0);
}, 10000)
$('#div3').delay(10000).fadeIn(0); //show interview
})
})
The code works fine but I want to implement the self-adjusting mechanism described on Sitepoint. Has anyone done this before or know how I can do this?
The HTML is here:
<div id="div1" class="div1">
<!--Show image button-->
<center>
<input type="button" id="btnclick" value="Show me Image" />
</center>
</div>
<div id="div2" class="main" style="display:none;">
<!--Image-->
<img src="timer.gif"/>
</div>
<div id="div3" class="main" style="display:none;">
<!--Form-->
<form> >
</form>
Thanks in advance.