Refactor scrolling and enhance UI accessibility.

Replaced inline JavaScript for scrolling and copy functionality with Angular methods. Introduced `ScrollService` for smooth scroll-to-top functionality and added associated styles. Removed unused `isHomePage` method and cleaned up components for better maintainability.
This commit is contained in:
2025-04-05 21:50:54 +02:00
parent c628f1e05b
commit dee84cc1a9
7 changed files with 87 additions and 10 deletions
+3 -4
View File
@@ -18,7 +18,7 @@
<h2 style="color: white;"><span class="player-count">Loading...</span></h2>
<h2 style="color: white;">Server IP: play.alttd.com</h2>
<!-- TODO make copy be angular not js-->
<button type="button" style="margin-top: 50px;" class="button-outer" onclick="copyToClipboard('play.alttd.com')">
<button type="button" style="margin-top: 50px;" class="button-outer" (click)="copyToClipboard('play.alttd.com')">
<span class="button-inner" id="copybutton">Copy IP</span>
</button>
</section>
@@ -140,13 +140,12 @@
<img ngSrc="/public/img/logos/log.png" alt="Alternative Altitude Server Logo" height="129"
width="120">
<h2 style="margin: 20px 0; font-size: 1.8em;">play.alttd.com</h2>
<!-- TODO make this use angular not js-->
<button type="button" class="button-outer" onclick="copyToClipboard('play.alttd.com')">
<button type="button" class="button-outer" (click)="copyToClipboard('play.alttd.com')">
<span class="button-inner" id="copybutton2">Copy IP</span>
</button>
</div>
</section>
<a href="#top" id="scrollupbutton">
<a (click)="this.scrollService.scrollToTop()" class="scroll-up-button, active">
<span></span>
<p style="display: none;">Scroll Down</p>
</a>
+3 -2
View File
@@ -1,6 +1,7 @@
import {Component, OnInit} from '@angular/core';
import {Title} from '@angular/platform-browser';
import {ALTITUDE_VERSION} from '../constant';
import {ScrollService} from '../scroll/scroll.service';
@Component({
standalone: false,
@@ -9,7 +10,7 @@ import {ALTITUDE_VERSION} from '../constant';
styleUrl: './home.component.scss'
})
export class HomeComponent implements OnInit {
constructor(private titleService: Title) {
constructor(private titleService: Title, public scrollService: ScrollService) {
}
private slides: string[] = ["/public/img/backgrounds/caruselimage2.png",
@@ -70,7 +71,7 @@ export class HomeComponent implements OnInit {
return slide == this.slideIndex ? 'active-dot' : 'inactive-dot';
}
scrollToSection(): void {
public scrollToSection(): void {
const element = document.getElementById('scrollingpoint');
if (element) {
element.scrollIntoView({behavior: 'smooth', block: 'start'});