I have two mat tables side by side on a horizontal plane
the one on the left is there to materialize "pinned" columns, the one on the right is scrollable both vertically and horizontally.
I now want to sync up both table's scrolling, as in, the left one isn't going to have a scroll bar and the right one is
I want the right one's scroll to always be automatically applied to the left one.
this will male both look like a single table with columns pinned on the left.
I'm asking this here because I only found solutions that are very "jquery" such as : Synchronized scrolling using jQuery?
and thus far I've striving to be as "google standard" as it gets in my angular 6 project. my code is very ECMAScript and angular - oriented I've little to no jquery.
and I'm worried about performance and whatever code I use eventually not keeping up and eventually breaking the illusion.
is jquery really the best way to do this?
UPDATE 1 :
so far I've got (DOM) :
<!--1-->
<mat-table #table1 [dataSource]="dataSource" matSort class="pinned catching-scrolling">
<--lots of dom...-->
<!--2-->
<mat-table #table2 [dataSource]="dataSource" matSort class="unpinned" (scroll)="syncScroll(table2)">
<--more dom...-->
ts :
syncScroll(div){
const d1 = this.element.nativeElement.querySelector('.catching-scrolling');
console.log(d1 , div);
d1.scrollTop = div.scrollTop;
}
now all of these : #table2 (scroll)="syncScroll(table2)"
, (scroll)="syncScroll(element)"
, (scroll)="syncScroll($event)"
are pretty good since they do send back elements that I could theoretically sync with but I just want to clean this up so that my dom is already sending the right thing from which I can point to scrollTop or the likes for both.
right now I have differing items on both.
UPDATE 2
(scroll)="syncScroll($event.srcElement)
sends back the right element and this makes for minimal code where the scrollbars actually do sync up :)
now the question remains : is using jquery (even in this Angular-ish manner) the fastest, most optimized solution?