2022-01-13 17:14:09 +01:00
|
|
|
import {Component, HostListener, Input, OnInit, ViewEncapsulation} from "@angular/core";
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* <section-scroll [customClass]="'optional classes for grid e.g. uk-flex-bottom'">
|
|
|
|
* <div fixed>...</div>
|
|
|
|
* <div scroll>...</div> # use uk-flex-first to change order
|
|
|
|
* </section-scroll>
|
|
|
|
*
|
|
|
|
* */
|
|
|
|
@Component({
|
|
|
|
selector: 'section-scroll',
|
|
|
|
template: `
|
2022-01-19 23:47:29 +01:00
|
|
|
|
|
|
|
<!--<!–alternative–>-->
|
|
|
|
<!--<div class="section" [ngClass]="customClass">-->
|
|
|
|
<!-- <ng-content select="[top]"></ng-content>-->
|
|
|
|
<!-- <div class="uk-grid content" [ngClass]="childrenCustomClass">-->
|
|
|
|
<!-- <ng-content select="[left]"></ng-content>-->
|
|
|
|
<!-- <ng-content select="[scroll]"></ng-content>-->
|
|
|
|
<!-- </div>-->
|
|
|
|
<!--</div>-->
|
|
|
|
|
|
|
|
<div class="section uk-grid" [ngClass]="customClass">
|
|
|
|
<ng-content select="[top]"></ng-content>
|
|
|
|
<ng-content select="[left]"></ng-content>
|
|
|
|
<ng-content select="[scroll]"></ng-content>
|
|
|
|
</div>
|
2022-01-13 17:14:09 +01:00
|
|
|
`,
|
|
|
|
styleUrls: ['section-scroll.component.css'],
|
|
|
|
encapsulation: ViewEncapsulation.None
|
|
|
|
})
|
|
|
|
export class SectionScrollComponent implements OnInit {
|
|
|
|
|
|
|
|
@Input()
|
|
|
|
public customClass = null;
|
2022-01-19 23:47:29 +01:00
|
|
|
@Input()
|
|
|
|
public childrenCustomClass = null;
|
|
|
|
private absolute: HTMLCollectionOf<Element>;
|
2022-01-13 17:14:09 +01:00
|
|
|
private scroll: HTMLElement;
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
}
|
|
|
|
|
|
|
|
@HostListener('window:resize', ['$event'])
|
|
|
|
onResize(event) {
|
2022-01-19 23:47:29 +01:00
|
|
|
//this.setHeight();
|
2022-01-13 17:14:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
2022-01-19 23:47:29 +01:00
|
|
|
//this.setHeight();
|
2022-01-17 18:46:22 +01:00
|
|
|
}
|
2022-01-19 23:47:29 +01:00
|
|
|
|
2022-01-17 18:46:22 +01:00
|
|
|
setHeight() {
|
|
|
|
if(typeof document !== "undefined") {
|
2022-01-19 23:47:29 +01:00
|
|
|
// this.absolute = document.querySelector('[absolute]');
|
|
|
|
this.absolute = document.getElementsByClassName('absolute');
|
2022-01-17 18:46:22 +01:00
|
|
|
this.scroll = document.querySelector('[scroll]');
|
|
|
|
this.scroll.setAttribute('style','max-height: ' + this.height + 'px;');
|
2022-01-19 23:47:29 +01:00
|
|
|
|
2022-01-17 18:46:22 +01:00
|
|
|
}
|
2022-01-13 17:14:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
get height():number {
|
2022-01-19 23:47:29 +01:00
|
|
|
let htmlElement = this.absolute&&this.absolute.length>0?this.absolute[0]:null;
|
|
|
|
return htmlElement?htmlElement['offsetHeight']:0;
|
2022-01-13 17:14:09 +01:00
|
|
|
}
|
|
|
|
}
|