Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://jsfiddle.net/K8Tuy/28/" rel="nofollow">http://jsfiddle.net/K8Tuy/28/</a> here you go;</p> <p>So, you need to <code>removeEventListener</code> on every click if you also <code>addEventListener</code> on every click; Generally, its not a good idea to <code>addEventListener</code> on every click. It should be initialize once and your logic should be inside the buttons.</p> <pre><code>var currentPage = 0; function nextPage() { var pages = document.getElementsByClassName('pages'); pages[currentPage].className = "pages pageanim"; pages[currentPage].addEventListener('webkitAnimationEnd', function(){ this.style.left = '0%'; this.style.zIndex = currentPage; pages[currentPage].className = "pages"; currentPage = currentPage+1; this.removeEventListener('webkitAnimationEnd',arguments.callee,false); console.log(currentPage); }, false); } function previousPage() { //alert(currentPage); var pages = document.getElementsByClassName('pages'); page = pages[currentPage-1]; page.className = "pages revpageanim"; page.addEventListener('webkitAnimationEnd', function(){ currentPage = currentPage-1; this.style.left = '49%'; page.style.zIndex = pages.length-currentPage; page.className = "pages"; this.removeEventListener('webkitAnimationEnd',arguments.callee,false); console.log(currentPage); }, false); }​ </code></pre> <p>EDIT:<br /> <a href="http://jsfiddle.net/K8Tuy/35/" rel="nofollow">http://jsfiddle.net/K8Tuy/35/</a> -- <code>arguments.callee</code> replaced with "function name"</p>
    singulars
    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