SSR: dirty hack to fix initial blockchain scroll
This commit is contained in:
		
							parent
							
								
									abd7f62b20
								
							
						
					
					
						commit
						9cd33825bf
					
				@ -35,4 +35,10 @@
 | 
				
			|||||||
  </div>
 | 
					  </div>
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<ng-container *serverOnly>
 | 
				
			||||||
 | 
					  <!-- disgusting hack to apply an initial scroll to server-side rendered blockchain bar -->
 | 
				
			||||||
 | 
					  <img *ngIf="!stateService.isLiquid()" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="pixel" style="visibility: hidden; position: absolute;" onload="(() => { const b = document.getElementById('blockchain-container'); const d = document.getElementById('divider'); if (b && d) { b.scrollLeft = d.getBoundingClientRect().x - (window.innerWidth * (window.innerWidth >= 768 ? 0.5 : 0.95)); }})()">
 | 
				
			||||||
 | 
					  <img *ngIf="stateService.isLiquid()" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="pixel" style="visibility: hidden; position: absolute;" onload="(() => { const b = document.getElementById('blockchain-container'); const d = document.getElementById('divider'); if (b && d) { b.scrollLeft = d.getBoundingClientRect().x - (window.innerWidth >= 768 ? 420 : (window.innerWidth * 0.5)); }})()">
 | 
				
			||||||
 | 
					</ng-container>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<router-outlet></router-outlet>
 | 
					<router-outlet></router-outlet>
 | 
				
			||||||
 | 
				
			|||||||
@ -59,7 +59,7 @@ export class StartComponent implements OnInit, AfterViewChecked, OnDestroy {
 | 
				
			|||||||
  hasMenu = false;
 | 
					  hasMenu = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  constructor(
 | 
					  constructor(
 | 
				
			||||||
    private stateService: StateService,
 | 
					    public stateService: StateService,
 | 
				
			||||||
    private cd: ChangeDetectorRef,
 | 
					    private cd: ChangeDetectorRef,
 | 
				
			||||||
  ) {
 | 
					  ) {
 | 
				
			||||||
    this.isiOS = ['iPhone','iPod','iPad'].includes((navigator as any)?.userAgentData?.platform || navigator.platform);
 | 
					    this.isiOS = ['iPhone','iPod','iPad'].includes((navigator as any)?.userAgentData?.platform || navigator.platform);
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										19
									
								
								frontend/src/app/shared/directives/server-only.directive.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								frontend/src/app/shared/directives/server-only.directive.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
				
			|||||||
 | 
					import { Directive, TemplateRef, ViewContainerRef, Inject, PLATFORM_ID } from '@angular/core';
 | 
				
			||||||
 | 
					import { isPlatformServer } from '@angular/common';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Directive({
 | 
				
			||||||
 | 
					  selector: '[serverOnly]'
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					export class ServerOnlyDirective {
 | 
				
			||||||
 | 
					  constructor(
 | 
				
			||||||
 | 
					    private templateRef: TemplateRef<any>,
 | 
				
			||||||
 | 
					    private viewContainer: ViewContainerRef,
 | 
				
			||||||
 | 
					    @Inject(PLATFORM_ID) private platformId: Object
 | 
				
			||||||
 | 
					  ) {
 | 
				
			||||||
 | 
					    if (isPlatformServer(this.platformId)) {
 | 
				
			||||||
 | 
					      this.viewContainer.createEmbeddedView(this.templateRef);
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      this.viewContainer.clear();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -34,6 +34,7 @@ import { LanguageSelectorComponent } from '../components/language-selector/langu
 | 
				
			|||||||
import { FiatSelectorComponent } from '../components/fiat-selector/fiat-selector.component';
 | 
					import { FiatSelectorComponent } from '../components/fiat-selector/fiat-selector.component';
 | 
				
			||||||
import { RateUnitSelectorComponent } from '../components/rate-unit-selector/rate-unit-selector.component';
 | 
					import { RateUnitSelectorComponent } from '../components/rate-unit-selector/rate-unit-selector.component';
 | 
				
			||||||
import { BrowserOnlyDirective } from './directives/browser-only.directive';
 | 
					import { BrowserOnlyDirective } from './directives/browser-only.directive';
 | 
				
			||||||
 | 
					import { ServerOnlyDirective } from './directives/server-only.directive';
 | 
				
			||||||
import { ColoredPriceDirective } from './directives/colored-price.directive';
 | 
					import { ColoredPriceDirective } from './directives/colored-price.directive';
 | 
				
			||||||
import { NoSanitizePipe } from './pipes/no-sanitize.pipe';
 | 
					import { NoSanitizePipe } from './pipes/no-sanitize.pipe';
 | 
				
			||||||
import { MempoolBlocksComponent } from '../components/mempool-blocks/mempool-blocks.component';
 | 
					import { MempoolBlocksComponent } from '../components/mempool-blocks/mempool-blocks.component';
 | 
				
			||||||
@ -134,6 +135,7 @@ import { OnlyVsizeDirective, OnlyWeightDirective } from './components/weight-dir
 | 
				
			|||||||
    FiatCurrencyPipe,
 | 
					    FiatCurrencyPipe,
 | 
				
			||||||
    ColoredPriceDirective,
 | 
					    ColoredPriceDirective,
 | 
				
			||||||
    BrowserOnlyDirective,
 | 
					    BrowserOnlyDirective,
 | 
				
			||||||
 | 
					    ServerOnlyDirective,
 | 
				
			||||||
    BlockchainComponent,
 | 
					    BlockchainComponent,
 | 
				
			||||||
    BlockViewComponent,
 | 
					    BlockViewComponent,
 | 
				
			||||||
    EightBlocksComponent,
 | 
					    EightBlocksComponent,
 | 
				
			||||||
@ -267,6 +269,7 @@ import { OnlyVsizeDirective, OnlyWeightDirective } from './components/weight-dir
 | 
				
			|||||||
    FeeRoundingPipe,
 | 
					    FeeRoundingPipe,
 | 
				
			||||||
    ColoredPriceDirective,
 | 
					    ColoredPriceDirective,
 | 
				
			||||||
    BrowserOnlyDirective,
 | 
					    BrowserOnlyDirective,
 | 
				
			||||||
 | 
					    ServerOnlyDirective,
 | 
				
			||||||
    NoSanitizePipe,
 | 
					    NoSanitizePipe,
 | 
				
			||||||
    BlockchainComponent,
 | 
					    BlockchainComponent,
 | 
				
			||||||
    MempoolBlocksComponent,
 | 
					    MempoolBlocksComponent,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user