<commit_before>import {
    Component, Input, OnInit, ElementRef, HostBinding, AfterViewInit, ViewEncapsulation,
    EventEmitter, Output
} from '@angular/core';
import { Observable ,  Subscription } from 'rxjs';
import { VgAPI } from '../core/services/vg-api';
import { VgControlsHidden } from './../core/services/vg-controls-hidden';

import { VgStates } from '../core/states/vg-states';
import {fromEvent} from 'rxjs';

@Component({
    selector: 'vg-controls',
    encapsulation: ViewEncapsulation.None,
    template: `<ng-content></ng-content>`,
    styles: [ `
        vg-controls {
            position: absolute;
            display: flex;
            width: 100%;
            height: 50px;
            z-index: 300;
            bottom: 0;
            background-color: rgba(0, 0, 0, 0.5);
            -webkit-transition: bottom 1s;
            -khtml-transition: bottom 1s;
            -moz-transition: bottom 1s;
            -ms-transition: bottom 1s;
            transition: bottom 1s;
        }

        vg-controls.hide {  
            bottom: -50px;
        }
    `]
})
export class VgControls implements OnInit, AfterViewInit {
    elem: HTMLElement;
    target: any;

    @HostBinding('style.pointer-events') isAdsPlaying: string = 'initial';
    @HostBinding('class.hide') hideControls: boolean = false;

    @Input() vgFor: string;
    @Input() vgAutohide: boolean = false;
    @Input() vgAutohideTime: number = 3;

    private timer: any;
    private hideTimer: any;

    mouseMove$: Observable<any>;
    touchStart$: Observable<any>;

    subscriptions: Subscription[] = [];

    constructor(private API: VgAPI, private ref: ElementRef, private hidden: VgControlsHidden) {
        this.elem = ref.nativeElement;
    }

    ngOnInit() {
        this.mouseMove$ = fromEvent(this.API.videogularElement, 'mousemove');
        this.subscriptions.push(this.mouseMove$.subscribe(this.show.bind(this)));

        this.touchStart$ = fromEvent(this.API.videogularElement, 'touchstart');
        this.subscriptions.push(this.touchStart$.subscribe(this.show.bind(this)));<commit_msg>perf(VgControls): fix memory leaks<commit_after>import {
    Component, Input, OnInit, ElementRef, HostBinding, AfterViewInit, ViewEncapsulation,
    EventEmitter, Output, OnDestroy
} from '@angular/core';
import { Observable ,  Subscription } from 'rxjs';
import { VgAPI } from '../core/services/vg-api';
import { VgControlsHidden } from './../core/services/vg-controls-hidden';

import { VgStates } from '../core/states/vg-states';
import {fromEvent} from 'rxjs';

@Component({
    selector: 'vg-controls',
    encapsulation: ViewEncapsulation.None,
    template: `<ng-content></ng-content>`,
    styles: [ `
        vg-controls {
            position: absolute;
            display: flex;
            width: 100%;
            height: 50px;
            z-index: 300;
            bottom: 0;
            background-color: rgba(0, 0, 0, 0.5);
            -webkit-transition: bottom 1s;
            -khtml-transition: bottom 1s;
            -moz-transition: bottom 1s;
            -ms-transition: bottom 1s;
            transition: bottom 1s;
        }

        vg-controls.hide {  
            bottom: -50px;
        }
    `]
})
export class VgControls implements OnInit, AfterViewInit, OnDestroy {
    elem: HTMLElement;
    target: any;

    @HostBinding('style.pointer-events') isAdsPlaying: string = 'initial';
    @HostBinding('class.hide') hideControls: boolean = false;

    @Input() vgFor: string;
    @Input() vgAutohide: boolean = false;
    @Input() vgAutohideTime: number = 3;

    private timer: any;
    private hideTimer: any;

    mouseMove$: Observable<any>;
    touchStart$: Observable<any>;

    subscriptions: Subscription[] = [];

    constructor(private API: VgAPI, private ref: ElementRef, private hidden: VgControlsHidden) {
        this.elem = ref.nativeElement;
    }

    ngOnInit() {
        this.mouseMove$ = fromEvent(this.API.videogularElement, 'mousemove');
        this.subscriptions.push(this.mouseMove$.subscribe(this.show.bind(this)));

        this.touchStart$ = fromEvent(this.API.videogularElement, 'touchstart');
        this.subscriptions.push(this.touchStart$.subscribe(this.show.bind(this)));
{'fraction_non_alphanumeric': 0.13183431952662722, 'fraction_numerical': 0.010414201183431953, 'mean_word_length': 2.72663139329806, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '4524953', 'n_tokens_mistral': 1330, 'n_tokens_neox': 1256, 'n_words': 280}