{"size": 2855, "ext": "js", "max_stars_repo_path": "src/app/modules/core/layout/scroll.js", "max_stars_repo_name": "flatlogic/dashboard", "max_stars_repo_stars_event_min_datetime": "2016-01-20T19:50:49.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-24T13:54:36.000Z", "max_issues_repo_path": "src/app/modules/core/layout/scroll.js", "max_issues_repo_name": "flatlogic/dashboard", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/app/modules/core/layout/scroll.js", "max_forks_repo_name": "flatlogic/dashboard", "max_forks_repo_forks_event_min_datetime": "2016-01-20T19:50:54.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-13T18:43:52.000Z"}
{"max_stars_count": 17, "max_issues_count": null, "max_forks_count": 9, "avg_line_length": 41.9852941176, "max_line_length": 111, "alphanum_fraction": 0.4024518389}
(function () {
    'use strict';

    angular
        .module('qorDash.core')
        .directive('horizontalScroll', $HorizontalScroll);

    $HorizontalScroll.$inject = ['jQuery'];
    function $HorizontalScroll($) {
        return {
            restrict: 'ECA',
            terminal: true,
            priority: 400,
            link: function (scope, $element) {
                var hasScrollBar = function ($el) {
                        return $el.length && $el.get(0).scrollHeight > $el.get(0).clientHeight;
                    },
                    hasScrollBarUpwards = function ($el, $till) {
                        if ($el == $till || !$till.has($el).length) {
                            return false
                        }
                        if (hasScrollBar($el)) {
                            return true;
                        }
                        return hasScrollBarUpwards($el.parent(), $till);
                    },
                    isHorizontal = function ($el) {
                        return !hasScrollBar($el.closest('.qor-sheet-content'));
                    },
                    isScrolling = false,
                    previousHorizontal = false,
                    scrollingTimeout;
                $element[0].addEventListener('mousewheel', function (event) {
                    var $target = $(event.target),
                        continuePropagation;
                    if (hasScrollBarUpwards($target, $target.closest('.qor-sheet-content'))) {
                        return
                    }
                    if (isHorizontal($target) || isScrolling && previousHorizontal) {
                        if ($(window).width() >= 768) { // no horizontal scrolling for mobile. only for tablet+
                            if ($element[0].doScroll) {
                                $element[0].doScroll(event.wheelDelta > 0 ? 'left' : 'right');
                            } else if ((event.wheelDelta || event.detail) > 0) {
                                $element[0].scrollLeft -= 20;
                            } else {
                                $element[0].scrollLeft += 20;
                            }
                            continuePropagation = false;
                            previousHorizontal = true;
                        }
                        event.preventDefault();
                    } else {
                        previousHorizontal = false;
                    }
                    isScrolling = true;
                    clearTimeout(scrollingTimeout);
                    scrollingTimeout = setTimeout(function () {
                        isScrolling = false;
                        previousHorizontal = false;
                    }, 400);
                    return continuePropagation;
                });
            }
        };
    }

})();
