<commit_before>'use strict';

angular.module('em.directives').directive('emSwiper', ['$rootScope', 'Enum', 'location', 'userPrefix', 'swiperSlides', function($rootScope, Enum, location, userPrefix, swiperSlides) {
  return {
    restrict: 'A',
    link: function(scope, element) {
      var swiper;

      function changePath() {
        scope.feature = swiper.getSlide(swiper.activeIndex).getData('feature');
        location.skipReload().path('/' + userPrefix.getPrefix() + swiper.getSlide(swiper.activeIndex).getData('path'));
        $rootScope.$apply();
      }

      function emOnSlideChangeEnd(sw) {
        $rootScope.slideIndex = sw.activeIndex;
        changePath();
      }

      $rootScope.slideIndex = swiperSlides.getInitiaSlideIndex();

      // http://www.idangero.us/sliders/swiper/api.php
      swiper = new Swiper(element[0], {
        // mode: 'vertical',
        freeModeFluid: true,
        initialSlide: swiperSlides.getInitiaSlideIndex(),
        noSwiping: true,
        // simulateTouch: true,
        queueStartCallbacks: true,
        queueEndCallbacks: true,
        visibilityFullFit: true,

        onSlideChangeEnd: emOnSlideChangeEnd,
      });

      var top = false;
      var bottom = false;
      var up = false;
      var down = false;
      var startY, distY;

      function slideTouchStart() {
        var touchobj = event.changedTouches[0];
        startY = touchobj.pageY;
      }

      function slideTouchMove() {
        /*jshint validthis: true */
        var touchobj = event.changedTouches[0];
        distY = touchobj.pageY - startY;

        if (distY < 0) {
          down = true;
          up = false;
        } else {
          down = false;
          up = true;
        }

        if (this.scrollHeight - this.scrollTop <= this.clientHeight && down) {
          bottom = true;
        } else if (this.scrollTop <= 0 && up) {
          top = true;
        } else {
          bottom = false;
          top = false;
          event.stopPropagation();
        }
      }

      // swiper.getSlide(2).addEventListener('touchstart', slideTouchStart, false);
      // swiper.getSlide(2).addEventListener('touchmove', slideTouchMove, false);

      scope.nextSlide = function() {
        swiper.swipeNext();
      };

      scope.prevSlide = function() {
        swiper.swipePrev();
      };

      scope.gotoHome = function() {
        swiper.swipeTo(Enum.MY);
      };

      scope.gotoTasks = function() {
        swiper.swipeTo(Enum.TASKS);<commit_msg>Vertical swipe alpha.<commit_after>'use strict';

angular.module('em.directives').directive('emSwiper', ['$rootScope', 'Enum', 'location', 'userPrefix', 'swiperSlides', function($rootScope, Enum, location, userPrefix, swiperSlides) {
  return {
    restrict: 'A',
    link: function(scope, element) {
      var swiper;

      function changePath() {
        scope.feature = swiper.getSlide(swiper.activeIndex).getData('feature');
        location.skipReload().path('/' + userPrefix.getPrefix() + swiper.getSlide(swiper.activeIndex).getData('path'));
        $rootScope.$apply();
      }

      function emOnSlideChangeEnd(sw) {
        $rootScope.slideIndex = sw.activeIndex;
        changePath();
      }

      $rootScope.slideIndex = swiperSlides.getInitiaSlideIndex();

      // http://www.idangero.us/sliders/swiper/api.php
      swiper = new Swiper(element[0], {
        mode: 'vertical',
        freeModeFluid: true,
        initialSlide: swiperSlides.getInitiaSlideIndex(),
        noSwiping: true,
        // simulateTouch: true,
        queueStartCallbacks: true,
        queueEndCallbacks: true,
        visibilityFullFit: true,

        onSlideChangeEnd: emOnSlideChangeEnd,
      });

      var top = false;
      var bottom = false;
      var up = false;
      var down = false;
      var startY, distY;

      function slideTouchStart() {
        var touchobj = event.changedTouches[0];
        startY = touchobj.pageY;
      }

      function slideTouchMove() {
        /*jshint validthis: true */
        var touchobj = event.changedTouches[0];
        distY = touchobj.pageY - startY;

        if (distY < 0) {
          down = true;
          up = false;
        } else {
          down = false;
          up = true;
        }

        if (this.scrollHeight - this.scrollTop <= this.clientHeight && down) {
          bottom = true;
        } else if (this.scrollTop <= 0 && up) {
          top = true;
        } else {
          bottom = false;
          top = false;
          event.stopPropagation();
        }
      }

      swiper.getSlide(2).addEventListener('touchstart', slideTouchStart, false);
      swiper.getSlide(2).addEventListener('touchmove', slideTouchMove, false);

      scope.nextSlide = function() {
        swiper.swipeNext();
      };

      scope.prevSlide = function() {
        swiper.swipePrev();
      };

      scope.gotoHome = function() {
        swiper.swipeTo(Enum.MY);
      };

      scope.gotoTasks = function() {
        swiper.swipeTo(Enum.TASKS);
{'fraction_non_alphanumeric': 0.1288196524865189, 'fraction_numerical': 0.0027960854803275414, 'mean_word_length': 2.1716276124129195, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7588016', 'n_tokens_mistral': 1539, 'n_tokens_neox': 1508, 'n_words': 283}