我正在使用ngx-twitter-timeline来获取最新的tweets更新。
第一次加载页面时,单击tweet按钮后,我可以获得最近的tweet。如果再次单击,则不会显示鸣叫,但可以看到它们占用的空间。
如果我转到页面或重新加载页面,则会显示鸣叫。
HTML
<mat-toolbar class="olc-menu" fxLayoutAlign="center center">
<button mat-fab color="primary" [matMenuTriggerFor]="menu" (click)="openMegaMenu()">Tweets</button>
<mat-menu #menu="matMenu" [overlapTrigger]="false" class="mega-menu app-dropdown">
<div fxLayout="row wrap">
<div fxFlex="25" fxLayout="column" class="p-1">
</div>
<div fxFlex="50" fxLayout="column" class="p-1">
<a mat-menu-item routerLink="/"><b>Twitter</b></a>
<mat-divider></mat-divider>
<ngx-twitter-timeline
[data]="{sourceType: 'url', url: 'https://twitter.com/RajuOakLiquor' }"
[opts]="{tweetLimit: 10}"
></ngx-twitter-timeline>
</div>
<div fxFlex="25" fxLayout="column" class="p-1">
</div>
</div>
</mat-menu>
</mat-toolbar>
<!-- <div fxLayout="row wrap">
<div fxFlex="100" fxLayout="column" class="p-1">
<mat-accordion>
<mat-expansion-panel (opened)="panelOpenState = true" (closed)="panelOpenState = false">
<mat-expansion-panel-header>
<mat-panel-title>
Twitter
</mat-panel-title>
<mat-panel-description>
Trending Tweets {{panelOpenState ? 'open' : 'closed'}}
</mat-panel-description>
</mat-expansion-panel-header>
<!-- <div fxLayout="row wrap">
<div fxFlex="100" fxLayout="column" class="p-1"> -->
<!-- <a mat-menu-item routerLink="/"><b>Twitter</b></a>
<mat-divider></mat-divider>
<ngx-twitter-timeline [data]="{sourceType: 'url', url: 'https://twitter.com/RajuOakLiquor' }"
[opts]="{tweetLimit: 10}"></ngx-twitter-timeline> -->
<!-- </div>
</div> -->
<!-- </mat-expansion-panel>
</mat-accordion>
</div>
</div> -->
Component.ts
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-socialmedia',
templateUrl: './socialmedia.component.html',
styleUrls: ['./socialmedia.component.scss']
})
export class SocialmediaComponent implements OnInit {
constructor() { }
ngOnInit() {
}
openMegaMenu(){
let pane = document.getElementsByClassName('cdk-overlay-pane');
[].forEach.call(pane, function (el) {
if(el.children.length > 0) {
if(el.children[0].classList.contains('mega-menu')){
el.classList.add('mega-menu-pane');
}
}
});
}
}
我的推特按钮:
页面首次加载时:
当我第二次单击按钮时: