feat(bookmarks): make split component work with dynamic header height

This commit is contained in:
Johannes Millan 2018-11-14 00:32:56 +01:00
parent aed3b91238
commit 294efe5e8d
2 changed files with 5 additions and 8 deletions

View file

@ -1,5 +1,4 @@
<main-header></main-header>
<h1>Yeahaha</h1>
<mat-sidenav-container>
<add-task-bar class="global"
[@blendInOut]

View file

@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component, EventEmitter, HostBinding, Input, OnInit, Output, Renderer2, ViewChild } from '@angular/core';
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnInit, Output, Renderer2, ViewChild } from '@angular/core';
import { fromEvent, Subscription } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
@ -42,7 +42,7 @@ export class SplitComponent implements OnInit {
this._renderer.addClass(this.splitTopEl, ANIMATABLE_CLASS);
this._renderer.addClass(this.splitBottomEl, ANIMATABLE_CLASS);
let newPos = 50;
if (this.pos === 50) {
if (this.pos > 45 && this.pos < 55) {
newPos = 100;
}
this._updatePos(newPos);
@ -76,13 +76,11 @@ export class SplitComponent implements OnInit {
this._renderer.removeClass(this.splitTopEl, ANIMATABLE_CLASS);
this._renderer.removeClass(this.splitBottomEl, ANIMATABLE_CLASS);
this._isDrag = true;
// console.log('onMouseDown', ev);
const bounds = this.containerEl.getBoundingClientRect();
const h = this.containerEl.offsetHeight;
// const handleHeight = this.buttonEl._elementRef.nativeElement.offsetHeight * 3 / 2;
const handleHeight = this.buttonEl._elementRef.nativeElement.offsetHeight * 2 / 2;
// console.log(handleHeight);
const headerHeight = bounds.top;
let percentage = (ev.clientY - handleHeight) / h * 100;
let percentage = (ev.clientY - headerHeight) / h * 100;
if (percentage > 100) {
percentage = 100;
}