{"size": 4993, "ext": "js", "max_stars_repo_path": "src/Armd/LectureBundle/Resources/public/js/autoscroll.js", "max_stars_repo_name": "damedia/culture.ru", "max_stars_repo_stars_event_min_datetime": "2015-03-20T16:11:37.000Z", "max_stars_repo_stars_event_max_datetime": "2015-03-20T16:11:37.000Z", "max_issues_repo_path": "src/Armd/LectureBundle/Resources/public/js/autoscroll.js", "max_issues_repo_name": "damedia/culture.ru", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Armd/LectureBundle/Resources/public/js/autoscroll.js", "max_forks_repo_name": "damedia/culture.ru", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 41.9579831933, "max_line_length": 95, "alphanum_fraction": 0.4133787302}
var autoScrolling = {
    autoScrollInt: null,
    autoScrollIntHor: null,
    state: false,
    init: function(){
        this.initVertical();
        this.initHorizontal();
        this.initHorizontalParent();
    },
    initVertical: function(){
        $(document).on(
            {
                mousemove: function(e) 
                {
                    var autoScroll = $(this),
                    autoScrollHeight = autoScroll.height(),
                    autoScrollWrapHeight = autoScroll.parent().height(),
                    autoScrollTop = autoScroll.position().top,
                    autoScrollTopMax = autoScrollWrapHeight - autoScrollHeight;
                    
                    var parentOffset = autoScroll.offset(); 
                    //or $(this).offset(); if you really just want the current element's offset
                    
                    var relY = e.pageY - parentOffset.top;
                    var state = relY > autoScrollHeight/2;
                    
                    console.log();
                    if (autoScrolling.state != state) {
                        autoScrolling.state = state;
                        if (relY > autoScrollHeight/2) {
                            autoScrolling.autoScrollInt = setInterval(function(){
                                if (autoScrollTop > autoScrollTopMax) {
                                    autoScrollTop -= 2;
                                    autoScroll.css({top:autoScrollTop});
                                } else {
                                    clearInterval(autoScrolling.autoScrollInt);
                                }
                            }, 100);
                        } else {
                            autoScroll.css('top', 0);
                            clearInterval(autoScrolling.autoScrollInt);
                        }
                    }
                    
                    
                    
                    /*
                         */
                },
                mouseleave: function()
                {
                    $(this).unbind('mouseover').css('top',0);
                    clearInterval(autoScrolling.autoScrollInt);
                    autoScrolling.state = false;
                }
            }
            , '.autoscrolling');
    },
    initHorizontal:function(){
        $(document).on(
            {
                mouseenter: function() 
                {
                    var autoScroll = $(this),
                        autoScrollWidth = autoScroll.width(),
                        autoScrollWrapWidth = autoScroll.parent().width(),
                        autoScrollLeft = autoScroll.position().left,
                        autoScrollLeftMax = autoScrollWrapWidth - autoScrollWidth;
                        
                    //autoScroll.parent().css('text-overflow', 'auto');    
                        
                    autoScrolling.autoScrollIntHor = setInterval(function(){
                        if (autoScrollLeft > autoScrollLeftMax) {
                            autoScrollLeft -= 5;
                            autoScroll.css({left:autoScrollLeft});
                        } else {
                            clearInterval(autoScrolling.autoScrollIntHor);
                        }
                    }, 100);    
                },
                mouseleave: function()
                {
                    $(this).unbind('mouseover').css({'left':0});
                    clearInterval(autoScrolling.autoScrollIntHor);
                }
            }
            , '.autoscrollingHor');
    },
    initHorizontalParent:function(){
        $(document).on(
            {
                mouseenter: function() 
                {
                    var autoScroll = $(this).find('.autoscrollingHorChild'),
                        autoScrollWidth = autoScroll.width(),
                        autoScrollWrapWidth = autoScroll.parent().width(),
                        autoScrollLeft = autoScroll.position().left,
                        autoScrollLeftMax = autoScrollWrapWidth - autoScrollWidth;
                        
                    //autoScroll.parent().css('text-overflow', 'auto');    
                        
                    autoScrolling.autoScrollIntHor = setInterval(function(){
                        if (autoScrollLeft > autoScrollLeftMax) {
                            autoScrollLeft -= 5;
                            autoScroll.css({left:autoScrollLeft});
                        } else {
                            clearInterval(autoScrolling.autoScrollIntHor);
                        }
                    }, 100);    
                },
                mouseleave: function()
                {
                    $(this).find('.autoscrollingHorChild').unbind('mouseover').css({'left':0});
                    clearInterval(autoScrolling.autoScrollIntHor);
                }
            }
            , '.autoscrollingHorParent');
    }
}