<commit_before>import {Renderer} from '@angular/core/src/render/api';
import {ViewChild} from '@angular/core/src/metadata/di';
import { NavigationStart } from '@angular/router/src/router';
import { Router } from '@angular/router/src/router';
import 'rxjs/add/operator/pairwise';
import { HostListener } from '@angular/core/src/metadata/directives';
import { Component, OnInit } from '@angular/core';
import {ElementRef} from '@angular/core';
@Component({
    selector: 'app-header',
    templateUrl: './header.component.html',
    styleUrls: ['./header.component.scss']
})
export class HeaderComponent {



    isTop: boolean = true;

    lastDirection: string;
    currentDirection: string;

    showNav: boolean = true;

    currentPosition: number;

    moveStart: number;
    moveLength: number;

    bigLogo: boolean = true;

    

    

    @HostListener('window:scroll', ['$event'])
    doSomething(event) {


        this.isTop = document.body.scrollTop < 50;

        this.currentDirection = (document.body.scrollTop > this.currentPosition) ? 'down' : 'up';

        if (this.currentDirection != this.lastDirection) {
            this.moveStart = document.body.scrollTop;
            this.moveLength = 0;
            this.lastDirection = this.currentDirection;
        }
        else {
            this.moveLength = Math.abs(this.moveStart - document.body.scrollTop);
        }

        this.currentPosition = document.body.scrollTop;

        if (this.currentDirection == 'down') {
            if (this.isTop) {
                this.bigLogo = true;
                this.showNav = true;
            }
            else {
                if (this.moveLength > 100) {
                    this.bigLogo = false;
                }
                else if (this.moveLength > 50) {
                    this.showNav = false;
                }
            }
        }
        else {
            if (this.isTop) {
                this.bigLogo = true;
                this.showNav = true;
            }
            else {
                if (this.moveLength > 50) {
                    this.showNav = true;
                    this.bigLogo = false;
                }
            }

        }

    }

    @ViewChild('test') el:ElementRef;
    constructor(private router: Router, private rd: Renderer) {

        this.router.events.pairwise().subscribe((e) => {
            console.log(e);
            if (e[1] instanceof NavigationStart) {
                this.rd.invokeElementMethod(this.el.nativeElement,'click');
            }
        });

    }

}
<commit_msg>navbar在FF不會消失的Bug<commit_after>import {Renderer} from '@angular/core/src/render/api';
import {ViewChild} from '@angular/core/src/metadata/di';
import { NavigationStart } from '@angular/router/src/router';
import { Router } from '@angular/router/src/router';
import 'rxjs/add/operator/pairwise';
import { HostListener } from '@angular/core/src/metadata/directives';
import { Component, OnInit } from '@angular/core';
import {ElementRef} from '@angular/core';
@Component({
    selector: 'app-header',
    templateUrl: './header.component.html',
    styleUrls: ['./header.component.scss']
})
export class HeaderComponent {



    isTop: boolean = true;

    lastDirection: string;
    currentDirection: string;

    showNav: boolean = true;

    currentPosition: number;

    moveStart: number;
    moveLength: number;

    bigLogo: boolean = true;

    

    

    @HostListener('window:scroll', ['$event'])
    doSomething(event) {

        var scrollY = window.scrollY;

        this.isTop = scrollY < 50;

        this.currentDirection = (scrollY > this.currentPosition) ? 'down' : 'up';

        if (this.currentDirection != this.lastDirection) {
            this.moveStart = scrollY;
            this.moveLength = 0;
            this.lastDirection = this.currentDirection;
        }
        else {
            this.moveLength = Math.abs(this.moveStart - scrollY);
        }

        this.currentPosition = scrollY;

        if (this.currentDirection == 'down') {
            if (this.isTop) {
                this.bigLogo = true;
                this.showNav = true;
            }
            else {
                if (this.moveLength > 100) {
                    this.bigLogo = false;
                }
                else if (this.moveLength > 50) {
                    this.showNav = false;
                }
            }
        }
        else {
            if (this.isTop) {
                this.bigLogo = true;
                this.showNav = true;
            }
            else {
                if (this.moveLength > 50) {
                    this.showNav = true;
                    this.bigLogo = false;
                }
            }

        }

    }

    @ViewChild('test') el:ElementRef;
    constructor(private router: Router, private rd: Renderer) {

        this.router.events.pairwise().subscribe((e) => {
            console.log(e);
            if (e[1] instanceof NavigationStart) {
                this.rd.invokeElementMethod(this.el.nativeElement,'click');
            }
        });

    }

}

{'fraction_non_alphanumeric': 0.12062180243998426, 'fraction_numerical': 0.004329004329004329, 'mean_word_length': 1.7357373519913886, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '346253', 'n_tokens_mistral': 1498, 'n_tokens_neox': 1400, 'n_words': 277}