There is a hidden iframe block that is in the body. There are projects on the site that have a link to the project card. But when you click on a project, an ajax request occurs that sends the card page to a hidden iframe. Iframe from here unfolds smoothly and fills the entire screen page. The ascent begins at the center of the screen. Question. Is it possible to make this block ascend from where the project clicked, that is, iframe starts from the center of the project block and not from the center of the whole body. Here is the implementation of my code
$( document ).ready(function() { $(".case_item_mob .case_link_<?php echo $post->ID ?>").on("click", function(e) { e.preventDefault(); $.ajax({ url: "<?php the_permalink(); ?>", success: function(data){ $("#frame").attr("src", "<?php the_permalink(); ?>"); $('.iframe_project, #frame').css({ 'background-repeat':'no-repeat', 'background-position':'center', 'background-size':'cover', 'position':'fixed', 'top':'0', 'left':'0', 'width':'100%', 'height':'100%', 'z-index':'100', }); $('#frame').removeClass('animated zoomOut'); $('#frame').addClass('animated zoomIn'); $('.iframe_project, #frame').fadeIn(); $("body").css("overflow", "hidden"); $('.close').fadeIn(); history.pushState(null, null, '<?php the_permalink(); ?>'); } }); }); $(".close").on("click", function(e){ e.preventDefault(); $('#frame').removeClass('animated zoomIn'); $('#frame').addClass('animated zoomOut'); $('#frame, .iframe_project').fadeOut(2100); $("body").css("overflow", "auto"); $('.close').fadeOut(); history.pushState(null, null, '/'); setTimeout(function(){ var frame = document.getElementById("frame"), frameDoc = frame.contentDocument || frame.contentWindow.document; frameDoc.documentElement.innerHTML = ""; }, 2100); }); });