Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery animating div after loading new image
    primarykey
    data
    text
    <p>I've sussed out most of the code, but something (small I know) is eluding me:</p> <p>I'm loading larger images into a div and resizing that div to match the new larger image dimensions. The div is faded in on thumbnail click, faded out on click, and changes to new resized content on clicking a new thumbnail (I'll add forward and back buttons later.)</p> <p>Everything works fine, except for the animation when the div resizes. I can't see the error in my code. Any help?</p> <p>HTML code:</p> <pre><code>&lt;div id="wrapper"&gt; &lt;div id="small"&gt;&lt;img src="images/small/001.jpg" width="100" height="125"&gt;&lt;img src="images/small/002.jpg" width="100" height="125"&gt;&lt;/div&gt; &lt;div id="large"&gt;&lt;img src="" /&gt;&lt;/div&gt; </code></pre> <p></p> <p>JQuery:</p> <pre><code>$(document).ready(function(){ $('#small img').click(function() { var image = $(this); var src = image.attr('src'); src = src.split('/'); var filename = src[src.length-1]; var image_folder = 'images/large/'; var large_image = $('#large img'); large_image.attr('src', image_folder + filename); new_height = $('#large img').height+"px"; new_width = $('#large img').width+"px"; $('#large').html(''); $('#large').append(large_image); if( $('#large').is(":visible") ) { $('#large').animate({ "height":new_height, "width":new_width }, {duration: 1000}) } else { $('#large').css('visibility','visible').hide(); $('#large').fadeIn(1000); } }); $('#large').click(function(){ $('#large').fadeOut(1000); //$('#large').hide(); }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload