{"size": 704, "ext": "js", "max_stars_repo_path": "homeworks/yulija.bon_Jul-Bon/5-rxjs/script.js", "max_stars_repo_name": "LigthWarrior/frontend-course-2020", "max_stars_repo_stars_event_min_datetime": "2020-10-09T08:16:54.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-14T07:45:10.000Z", "max_issues_repo_path": "homeworks/yulija.bon_Jul-Bon/5-rxjs/script.js", "max_issues_repo_name": "LigthWarrior/frontend-course-2020", "max_issues_repo_issues_event_min_datetime": "2020-10-20T19:29:38.000Z", "max_issues_repo_issues_event_max_datetime": "2021-02-19T08:21:07.000Z", "max_forks_repo_path": "homeworks/yulija.bon_Jul-Bon/5-rxjs/script.js", "max_forks_repo_name": "LigthWarrior/frontend-course-2020", "max_forks_repo_forks_event_min_datetime": "2020-10-07T12:37:57.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-15T07:13:54.000Z"}
{"max_stars_count": 6, "max_issues_count": 131, "max_forks_count": 63, "avg_line_length": 29.3333333333, "max_line_length": 71, "alphanum_fraction": 0.5866477273}
const { fromEvent } = window.rxjs;
const {
    filter, map, throttleTime, pairwise, distinctUntilChanged,
} = window.rxjs.operators;

const scroll = fromEvent(window, 'scroll');
const header = document.querySelector('.header');

scroll.pipe(
    throttleTime(250),
    map(() => window.pageYOffset),
    pairwise(),
    filter(([prev, curr]) => (prev - curr) > 50 || (curr - prev) > 50),
    map(([prev, curr]) => (prev < curr ? 'scrollDown' : 'scrollUp')),
    distinctUntilChanged(),
)
    .subscribe((event) => {
        if (event === 'scrollDown' && window.pageYOffset > 150) {
            header.classList.add('hide');
        } else {
            header.classList.remove('hide');
        }
    });
