Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It looks like you have a few problems in your javascript. View <a href="http://jsbin.com/ahide" rel="nofollow noreferrer">http://jsbin.com/ahide</a> for a working version and source code.</p> <p>First,</p> <pre><code>//Slideshow Image to hide rest var image = $('.projectPopup &gt; img'); image.hide().filter(':first').show(); </code></pre> <p>This code is going to hide all the images in the popups and then only show the first image in the collection which is inside the A.Effect projectPopup. Since you need to show the first image in each popup, loop through them individually like:</p> <pre><code>//Slideshow Image to hide rest $(".projectPopup").each(function(){ $("img", this).hide().filter(":first").show(); }); </code></pre> <p>The problem with resizing the popup has to do with getting the size of the first img using width() and height(). These methods will return 0 if the img is hidden in some way. To fix this, while looping through the projectPopups, temporarily show them off screen so you are able to get the width and height of the first image. This should fix that: </p> <pre><code>//Slideshow Image to hide rest $(".projectPopup").each(function(){ $("img", this).hide().filter(":first").show(); //Determine popup width and height var container = $(this); if (container.is(":hidden")) { container.css({ position: "absolute", visibility: "hidden", display: "block" }); } var popupWidth = container.find("img:first").width()+10; var popupHeight = container.find("img:first").height()+60; //Determine window width and height var windowWidth = document.documentElement.clientWidth; var windowHeight = document.documentElement.clientHeight; container.css("width" , popupWidth); container.css("height" , popupHeight); //Set popup CSS container.css({"position": "fixed", "background": "#000", "top": "10%", "left": "20%", visibility: "", display: "none"}); }); </code></pre> <p>Now, to get them centered in the middle of the screen, you can set the left property to (windowWidth / 2) - (popupWidth / 2) + "px"</p> <p>The whole $(document).ready() should be the following:</p> <pre><code>$(document).ready(function() { //Hiding all Divs $(".projectPopup").hide(); //Setting DIV name to nothing var actualOpenID = ""; //Slideshow Image to hide rest $(".projectPopup").each(function(){ $("img", this).hide().filter(":first").show(); //Determine popup width and height var container = $(this); if (container.is(":hidden")) { container.css({ position: "absolute", visibility: "hidden", display: "block" }); } var popupWidth = container.find("img:first").width()+10; var popupHeight = container.find("img:first").height()+60; //Determine window width and height var windowWidth = document.documentElement.clientWidth; var windowHeight = document.documentElement.clientHeight; container.css("width" , popupWidth); container.css("height" , popupHeight); //Set popup CSS container.css({"position": "fixed", "background": "#000", "top": "10%", "left": (windowWidth / 2) - (popupWidth / 2) + "px", visibility: "", display: "none"}); }); //Find &amp; Open $(".projectThumb").click(function(){ if (actualOpenID !== "") { $("div[id="+actualOpenID+"]").hide(); } var newID = $(this).children("img").attr("name"); $("div[id="+newID+"]").show(); actualOpenID = newID; }); $('ul.slideImages li a').click(function () { if (this.className.indexOf('active') == -1){ var images = $(this).closest(".projectPopup").find("img"); images.hide(); images.filter(this.hash).show(); $('ul.slideImages li a').removeClass('active'); $(this).addClass('active'); } return false; }); //Close property $("a.close").click(function (e) { e.preventDefault(); $(this).parent().hide(); actualOpenID = ""; }); }); </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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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