简体   繁体   English

对当前页面进行动画处理并加载新页面

[英]Animate and load new page over current page

So i have 5 portfolio items and what i'd like to happen when a user clicks on one is that the project details page animates and loads in over the page. 因此,我有5个项目组合项目,当用户单击一个项目时,我想发生的事情是项目详细信息页面会设置动画并加载到页面上。 Now i'v made a quick basis of how i thought this could work but not sure if this is the way to go. 现在,我已经快速了解了我认为这是如何工作的,但是不确定这是否可行。 Also not sure how i should load in the different content for the different projects if i do it like this.. 也不确定如果我这样做我应该如何为不同的项目加载不同的内容。

Now i just animate a hidden div over the whole page when one of the portfolio items is clicked. 现在,当单击投资组合项之一时,我只是在整个页面上设置一个隐藏的div动画。 Here is a fiddle so you guys get a better idea: 这是一个小提琴,所以你们有了一个更好的主意:

http://jsfiddle.net/MF32t/1/ http://jsfiddle.net/MF32t/1/

$(document).ready(function() {
$('.portfolio__project').click(function() { 
    $('.projectDetails').css({"display":"inline"});
    $('.projectDetails').animate({"width":"100%"}, 750);
    $('.projectDetails').delay(500).animate({"height":"100%"}, 750);
});

}); });

Is the the way to go? 是要走的路吗? Or should i think in a different direction? 还是我应该朝另一个方向思考? Don't need ready to go and working code but just need a push in the right direction. 不需要准备好去使用代码,而只需要朝着正确的方向推进即可。

Thanks! 谢谢!

You can use ajax to load the content. 您可以使用ajax加载内容。 A draft could look like this 草稿可能看起来像这样

function loadProject(projectID) {
  $.post(
    "loadProject.php",
    {
      projectID: projectID
    },
    function(content) {
      // Set the content
      $("#content").html(content); // and animations
    }
  );
}

You can also load the project details only in a main container, you don't need to hide the whole page. 您还可以仅在主容器中加载项目详细信息,而无需隐藏整个页面。 When loading the content you fade out the old one, set the new content and fade in the new one (for example). 加载内容时,淡出旧内容,设置新内容,然后淡入新内容(例如)。 It's your choice here 这是你的选择

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM