'use strict';

(function () {

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