1
동적 컨텐츠 (Ajax)가없는 jQuery없이 페이지 슬라이드 전환을 시도하고 있습니다. 나는 처음에는 CSS로 해보고 싶었지만 시도는 효과가 없었고 누구도 내 CSS question에 응답하지 않았습니다.Jquery가없는 페이지 슬라이드?
자바 스크립트로이 작업을 수행하기로 결정했지만 원하는 경우 클래스를로드 할 수 없습니다. 어떤 충고?
내 데모 시도 : Test Page
그리고 코드 :
자바 스크립트 :
function pageSlide (n) {
var slide = document.getElementById(n);
if(slide.className === 'aniDown') {
slide.className = 'aniUp'; }
else if (slide.className === 'aniUp'){
slide.className = 'aniDown'; } }
function sectionAssure(classID) {
pageSlide(classID);
setTimeout(function () {
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' }
sel[i].style.display = tmp; }
pageSlide(classID); }, (1000));
}
CSS :
.aniDown {
z-index:0;
-webkit-animation-name: slideDown;
-webkit-animation-duration: 2s;
-webkit-animation-iteration-count: 1;
-webkit-animation-timing-function: ease;
-webkit-animation-direction:normal;
}
@-webkit-keyframes slideDown {
0% { margin-top:-3000px; }
40% { margin-top:-100px; }
100% { margin-top:0px; }
}
.saniUp {
-webkit-animation-name: slideUp;
-webkit-animation-duration: 2s;
-webkit-animation-iteration-count: 1;
-webkit-animation-timing-function: ease;
-webkit-animation-direction:normal;
}
@-webkit-keyframes slideUp {
0% {margin-top:0px;}
20% {margin-top:-1000px;}
100% {margin-top:-3000px;}
}
HTML5 :
<header>
<nav id="headNav">
<ul>
<li><a href="#" onclick="checkPage('page1', 'home.html');return false">Home</a></li>
<li><a href="#" onclick="checkPage('page2', 'about.html');return false">About</a></li>
</ul>
</nav>
</header>
<!-- Content Areas: (Variable visual)-->
<div id="contentBody">
<br>
<section class="aniDown" id="page1">
<script>loadContent('page1','home.html');</script>
</section>
<section class="aniDown" id="page2"></section>
</div>
콘솔에 올바른 순서대로 작업을 수행 중이며 오류가없는 것으로 보입니다. 활성 버전에는이를 보여주는 console.log가 있습니다. –
쏴 버려! 그냥 classID라고 부르는 것을 알아 차렸습니다. 나는 그 페이지가 보이기도 전에 페이지를 호출하려고합니다. 결국이 작업을 시도하고 수정하도록 노력하겠습니다. –
Arrg, 그냥 .aniUp 클래스에서 오타가있는 것으로 나타났습니다. 잠시 시간을내어 몇 가지 일을 다시 시도해야합니다. –