<commit_before>"use strict";
/**
 * Angular wrapper for velocityjs
 * @author SOON_
 * @module sn.velocity.snVelocity
 * @class  snVelocity
 * @example
 *      <sn-velocity
 *          data-keyframes="[{'properties': { opacity: 0 }, 'options': { duration: 1000 }},{'properties': { opacity: 1 },'options': { duration: 1000 }}]"
 *          data-start-delay="1000"
 *      ></sn-velocity>
 */
angular.module("sn.velocity.snVelocity", []).directive("snVelocity",[
    "$window",
    "$timeout",
    /**
     * @constructor
     */
    function($window, $timeout) {
        return {
            restrict: "A",
            scope: {
                "keyframes": "=",
                "startDelay": "=?"
            },
            link: function($scope, $element){

                var timer;

                /**
                 * Run animation
                 * @method animate
                 */
                $scope.animate = function animate() {
                    angular.forEach($scope.keyframes, function(value){
                        $window.Velocity($element, value.properties, value.options);
                    });
                };

                /**
                 * Trigger animation, with loop or start delay on initialisation
                 * @method init
                 */
                $scope.init = function init() {

                    // start delay - run animation on init or with start delay
                    if ($scope.startDelay) {
                        timer = $timeout($scope.animate, $scope.startDelay);
                    } else {
                        $scope.animate();
                    }
                };

                /**
                 * Clear all listeners during angularjs garbage collection
                 * @method onDestroy
                 */
                $scope.onDestroy = function onDestroy() {
                    timer.cancel();
                };

                $scope.$on("$destroy", $scope.onDestroy);

                $scope.init();

            }
        };
    }
]);<commit_msg>cancel timer before creating new instance<commit_after>"use strict";
/**
 * Angular wrapper for velocityjs
 * @author SOON_
 * @module sn.velocity.snVelocity
 * @class  snVelocity
 * @example
 *      <sn-velocity
 *          data-keyframes="[{'properties': { opacity: 0 }, 'options': { duration: 1000 }},{'properties': { opacity: 1 },'options': { duration: 1000 }}]"
 *          data-start-delay="1000"
 *      ></sn-velocity>
 */
angular.module("sn.velocity.snVelocity", []).directive("snVelocity",[
    "$window",
    "$timeout",
    /**
     * @constructor
     */
    function($window, $timeout) {
        return {
            restrict: "A",
            scope: {
                "keyframes": "=",
                "startDelay": "=?"
            },
            link: function($scope, $element){

                var timer;

                /**
                 * Run animation
                 * @method animate
                 */
                $scope.animate = function animate() {
                    angular.forEach($scope.keyframes, function(value){
                        $window.Velocity($element, value.properties, value.options);
                    });
                };

                /**
                 * Trigger animation, with loop or start delay on initialisation
                 * @method init
                 */
                $scope.init = function init() {

                    // start delay - run animation on init or with start delay
                    if ($scope.startDelay) {
                        if (timer) {
                            $timeout.cancel(timer);
                        }

                        timer = $timeout($scope.animate, $scope.startDelay);
                    } else {
                        $scope.animate();
                    }
                };

                /**
                 * Clear all listeners during angularjs garbage collection
                 * @method onDestroy
                 */
                $scope.onDestroy = function onDestroy() {
                    if (timer) {
                        $timeout.cancel(timer);
                    }
                };

                $scope.$on("$destroy", $scope.onDestroy);

                $scope.init();

            }
        };
    }
]);
{'fraction_non_alphanumeric': 0.12612197928653626, 'fraction_numerical': 0.006444188722669736, 'mean_word_length': 1.141941843272548, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 7, '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': '334656', 'n_tokens_mistral': 1102, 'n_tokens_neox': 988, 'n_words': 220}