'use strict';

(function () {

  Animation.currentToRight = function (elem, current, prev) {
    var event = new Event('current-to-right');
    if (prev && !Animation.animating) {
      Animation.animating = true;
      addClass(prev, 'active');
      addClass(prev, 'anm-lft-to-crt');
      addClass(current, 'anm-crt-to-rgt');
      setTimeout(function () {
        removeClass(current, 'current');
        removeClass(current, 'anm-crt-to-rgt');
        removeClass(prev, 'anm-lft-to-crt');
        addClass(prev, 'current');
        removeClass(prev, 'active');
        window.scrollTo(0, 0);
        elem.dispatchEvent(event);
        Animation.animating = false;
      }, 600);
    }
  };
}());
