Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As Yotam has commented, difficult to debug without a jsFiddle. But things that stuck out to me (and in no way is this exhaustive and I am no JavaScript expert):</p> <ol> <li>cache your jQuery objects rather than keep requerying the DOM (var $sticker = $('.sticker'))</li> <li>Chain together your animations on the same objects</li> <li>What is the difference between $sticker.children(".wrap") and $sticker.find(".imgspace")? Can you not use $sticker.find(".wrap, .imgspace")?</li> </ol> <p>You could further simplify the code by setting your values to variable objects rather than call the same method twice hard coded with different values.</p> <pre><code>$("body").on('click', '.sticker', function () { if (!is_open) { var $position = $(this).position(), $sticker = $('.sticker'); $sticker.not(this).fadeOut(350, function () { $sticker.css({ position: 'absolute', left: $position.left+'px', top: $position.top+'px' }) .animate({ 'top': '0px', 'left': '300px', 'height': '480px', 'width': '750px', 'left': '90px' }, 350); $sticker.find(".wrap, .imgspace").animate({ 'height': '343px', 'width': '750px' }, 350); $sticker.find(".info").animate({ 'height': '100px' }, 350); $('.arrow-left').animate({ 'left': '-20px' }, 450) .animate({ 'left': '880px' }, 450); is_open = true; }); } if (is_open) { $sticker.find(".wrap, .imgspace").animate({ 'height': '193px', 'width': '300px' }, 350); $sticker.find(".info").animate({ 'height': '0px' }, 350); $sticker.animate({ 'height': '230px', 'width': '300px', 'top': $position.top, 'left': $position.left }, 350, function () { $sticker.css("position", "static") .not(this).fadeIn(300); is_open = false; }); } }); </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.
    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