[英]Animation with Ajax, and CSS3
I am creating a little script that allows me to slide my content sections in and out though Ajax and CSS. 我正在创建一个小脚本,该脚本使我可以通过Ajax和CSS滑动内容部分。 I have have successfully made it slide in on page loads from the top but I have one problem, sliding out!
我已经成功地使其从顶部滑入页面加载,但是我有一个问题,滑出!
I wrote a clip for 'aniOut' that works also but I cant seem to make one load before the other in transition. 我为'aniOut'编写了一个片段,该片段也可以使用,但是我似乎无法在转换之前先加载一个。 I have tried a few things but I either have the page lock up, stop loading, or simply not initiate correctly.
我已经尝试了一些方法,但是我要么将页面锁定,停止加载,要么根本无法正确启动。 I included the the working code with the whole 'aniIn' CSS because it contains ability to function on -moz -webkit but only the basic animation code for 'aniOut' to save on the space of my thread.
我将工作代码包含在整个“ aniIn” CSS中,因为它包含在-moz -webkit上运行的功能,但仅包含“ aniOut”的基本动画代码以节省线程空间。
Can someone push me towards a resources to help me learn what I need to do? 有人可以将我推向一种资源来帮助我学习我需要做的事情吗?
My site is live with the working slide in at The Mind Company . 我的网站和The Mind Company上的工作幻灯片一起使用 。
CSS: CSS:
header {
z-index:100;
position:relative;
display: block;
background-color: #272727;
height:100px;}
#contentBody {
min-height:48em;}
footer {
position:relative;
display: block;
background-color: #272727;
height:168px; }
#aboutPage {
display:none;}
#productPage {
display:none;}
#contactPage {
display:none;}
.aniIn {
z-index:0;
-webkit-animation-name: ANIMATEin;
-webkit-animation-duration: 1s;
-webkit-animation-iteration-count: 1;
-webkit-animation-timing-function: ease-in;
-moz-animation-name: ANIMATEin;
-moz-animation-duration: 1s;
-moz-animation-iteration-count: 1;
-moz-animation-timing-function: ease-in;
/* Currently Not Working in browsers: Is planed for implimentation in later versions. */
animation-name: ANIMATEin;
animation-duration: 1s;
animation-iteration-count: 1;
animation-timing-function: ease-in;
-ms-animation-name: ANIMATEin;
-ms-animation-duration: 1s;
-ms-animation-iteration-count: 1;
-ms-animation-timing-function: ease-in;
}
@-webkit-keyframes ANIMATEin {
from {
margin-top:-3000px;
}
to {
margin-top:0px;
}
}
@-moz-keyframes ANIMATEin {
from {
margin-top:-3000px;
}
to {
margin-top:0px;
}
}
@keyframes ANIMATEin {
from {
margin-top:-3000px;
}
to {
margin-top:0px;
}
}
.aniOut {
z-index:0;
animation-name: ANIMATEout;
animation-duration: 1s;
animation-iteration-count: 1;
animation-timing-function: ease-in;
}
@keyframes ANIMATEout {
from {
margin-top:0px;
}
to {
margin-top:3000px;
}
}
Java Script: Java脚本:
function $_(IDS) { return document.getElementById(IDS); }
function ani(){
document.getElementById(classID).className ='aniOut';
}
function checkPage(classID, url){
var tmp = '';
var sel = document.getElementsByTagName('section');
for (var i=0; i<sel.length; i++){
if (sel[i].id == classID) { tmp = 'block' } else { tmp = 'none' }
$_(classID).className ='aniIn';
sel[i].style.display = tmp;}
$_(classID).style.display = 'block';
loadContent(classID, url); }
function loadContent (classID, url){
var xmlhttp;
if (window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
document.getElementById(classID).innerHTML=xmlhttp.responseText;}}
xmlhttp.open("GET","content/"+url,true);
xmlhttp.send();}
and the HTML5: 和HTML5:
<!-- Header Areas: (Constent visual)-->
<header>
<li><a href="#" onclick="checkPage('aboutPage', 'about.html');return false">About</a></li>
<li><a href="#" onclick="checkPage('productPage', 'projects.html');return false">Projects</a></li>
<li><a href="#" onclick="checkPage('contactPage', 'contact.html');return false">Contact</a></li>
</header>
<!-- Content Areas: (Variable visual)-->
<div id="contentBody">
<section id="aboutPage"></section>
<section id="productPage"></section>
<section id="contactPage"></section>
</div>
<!-- Footer Area: (Constant visual)-->
<footer></footer>
previously posted with no answer at: Previous Post 以前没有答案发布在: 以前的帖子
I tried several ways after @Zeta referenced MDN website. @Zeta引用MDN网站后,我尝试了几种方法。 I decided to stay with animation element because I can set the effect such as a bounce or position movement speeds( progressive slow down ).
我决定保留动画元素,因为我可以设置诸如反弹或位置移动速度(逐级减速)的效果。
The first attempt I wanted to try pure CSS but I couldn't get it and I haven't received any feedback on why question to why . 第一次尝试我想尝试纯CSS,但我无法得到它,我还没有收到任何原因反馈问题为什么 。
Then I tried to do it with JavaScript and had some success. 然后,我尝试使用JavaScript进行操作,并取得了一些成功。 I do have one issue with the script right now but this is a official fix to what I was trying.
我的脚本现在确实有一个问题,但这是我正在尝试的正式修复。 (Note: Current issue is the first Link clicked will not transition, I may have a solution though)
(注意:当前问题是单击的第一个链接不会过渡,但是我可能有解决方案)
See the links for code solutions. 请参阅链接以获取代码解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.