<commit_before>(function () {

var adaptive = angular.module('adaptive.scroll', []);

adaptive.factory('$gyroscope', ['$rootScope', function ($rootScope) {

  var alphaStart, betaStart, gammaStart;
  var alpha, beta, gamma;
  var trashold = 20;
  var active;

  window.ondeviceorientation = function(event) {
    alpha = Math.round(event.alpha);
    beta = Math.round(event.beta);
    gamma = Math.round(event.gamma);

    if (active) {
      if ((Math.abs(alphaStart - alpha) > trashold) || (Math.abs(betaStart - beta) > trashold) || (Math.abs(gammaStart - gamma) > trashold)) {
        sendEvent();
      }
      else {
        sendEvent(0,0,0);
      }
    }
  };

  var sendEvent = function(a,b,c) {
    var alphaDiff = a || (alphaStart - alpha);
    var betaDiff = b || (betaStart - beta);
    var gammaDiff = c || (gammaStart - gamma);
    $rootScope.$broadcast('adaptive.scroll:deviceorientation', {'alphaDiff': alphaDiff, 'betaDiff': betaDiff, 'gammaDiff': gammaDiff});
  };

  var start = function(degrees) {
    alphaStart = alpha;
    betaStart = beta;
    gammaStart = gamma;
    trashold = degrees || trashold;
    active = true;
  };

  var stop = function() {
    active = false;
  };

  return {
    start: function() {
      start();
    },
    stop: function() {
      stop();
    }
  };

}]);

adaptive.directive('adaptivescroll', ['$rootScope', function ($rootScope) {
  return {
    restrict: 'A',
    link: function (scope, element, attrs) {
      var getOptions = function () {
        return angular.extend({}, scope.$eval(attrs.adaptivescroll));
      };
      var opts = getOptions();
      console.log(opts);

      window.requestAnimationFrame = (function(){
        return  window.requestAnimationFrame       ||
                window.webkitRequestAnimationFrame ||
                window.mozRequestAnimationFrame    ||
                function( callback ){
                  window.setTimeout(callback, 1000 / 60);
                };
      })();

      var alphaDiff = 0;
      var betaDiff = 0;
      var gammaDiff = 0;

      var scroll = function() {
        if (alphaDiff || betaDiff) {
          element.scrollTop = element.scrollTop + alphaDiff; 
          element.scrollLeft = element.scrollLeft + betaDiff;
        }
      };

      window.requestAnimationFrame(scroll);

      $rootScope.$on('adaptive.scroll:deviceorientation', function(e, data){
        var alphaDiff = data.alphaDiff;
        var betaDiff = data.betaDiff;
        var gammaDiff = data.gammaDiff;
      });

    }
  };
}]);


})();<commit_msg>alphaDiff, betaDiff, gamaDiff scope<commit_after>(function () {

var adaptive = angular.module('adaptive.scroll', []);

adaptive.factory('$gyroscope', ['$rootScope', function ($rootScope) {

  var alphaStart, betaStart, gammaStart;
  var alpha, beta, gamma;
  var trashold = 20;
  var active;

  window.ondeviceorientation = function(event) {
    alpha = Math.round(event.alpha);
    beta = Math.round(event.beta);
    gamma = Math.round(event.gamma);

    if (active) {
      if ((Math.abs(alphaStart - alpha) > trashold) || (Math.abs(betaStart - beta) > trashold) || (Math.abs(gammaStart - gamma) > trashold)) {
        sendEvent();
      }
      else {
        sendEvent(0,0,0);
      }
    }
  };

  var sendEvent = function(a,b,c) {
    var alphaDiff = a || (alphaStart - alpha);
    var betaDiff = b || (betaStart - beta);
    var gammaDiff = c || (gammaStart - gamma);
    $rootScope.$broadcast('adaptive.scroll:deviceorientation', {'alphaDiff': alphaDiff, 'betaDiff': betaDiff, 'gammaDiff': gammaDiff});
  };

  var start = function(degrees) {
    alphaStart = alpha;
    betaStart = beta;
    gammaStart = gamma;
    trashold = degrees || trashold;
    active = true;
  };

  var stop = function() {
    active = false;
  };

  return {
    start: function() {
      start();
    },
    stop: function() {
      stop();
    }
  };

}]);

adaptive.directive('adaptivescroll', ['$rootScope', function ($rootScope) {
  return {
    restrict: 'A',
    link: function (scope, element, attrs) {
      var getOptions = function () {
        return angular.extend({}, scope.$eval(attrs.adaptivescroll));
      };
      var opts = getOptions();
      console.log(opts);

      window.requestAnimationFrame = (function(){
        return  window.requestAnimationFrame       ||
                window.webkitRequestAnimationFrame ||
                window.mozRequestAnimationFrame    ||
                function( callback ){
                  window.setTimeout(callback, 1000 / 60);
                };
      })();

      var alphaDiff = 0;
      var betaDiff = 0;
      var gammaDiff = 0;

      var scroll = function() {
        if (alphaDiff || betaDiff) {
          element.scrollTop = element.scrollTop + alphaDiff; 
          element.scrollLeft = element.scrollLeft + betaDiff;
        }
      };

      window.requestAnimationFrame(scroll);

      $rootScope.$on('adaptive.scroll:deviceorientation', function(e, data){
        alphaDiff = data.alphaDiff;
        betaDiff = data.betaDiff;
        gammaDiff = data.gammaDiff;
      });

    }
  };
}]);


})();
{'fraction_non_alphanumeric': 0.14280125195618154, 'fraction_numerical': 0.005477308294209703, 'mean_word_length': 2.443097643097643, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3357567', 'n_tokens_mistral': 1609, 'n_tokens_neox': 1506, 'n_words': 324}