Hi all, when I go to http://localhost:4200/myroute , a script is supposed to trigger:
bar = document.querySelector('.progress-bar'),
counter = document.querySelector('.count'),
i = 0,
throttle = 0.2; // 0-1
(function draw() {
if(i <= 100) {
var r = Math.random();
requestAnimationFrame(draw);
bar.style.width = i + '%';
counter.innerHTML = Math.round(i) + '%';
if(r < throttle) { // Simulate d/l speed and uneven bitrate
i = i + r;
}
} else {
setTimeout(function() {
bar.className += ' done'; // Add the "done" class for fading effect
counter.style.transition = 'opacity 1s'; // Apply transition to counter
bar.style.opacity = '0'; // Fade out the bar
counter.style.opacity = '0'; // Fade out the percentage
}, 1500);
setTimeout(function() {
$('#progress-bar-container').addClass('hidden')
$('.carousel-container').removeClass('hidden')
},1500)
}
})();
It's kind of a loading bar.
It triggers when I manually type in the browser the link to the route. However, when trying to redirect using a routerlink:
<div class="row justify-content-center">
<div class="glowing-btn-wrapper mt-3 mr-3">
<button type="submit" class='glowing-btn' [routerLink]="'/recommendit'" routerLinkActive="router-link-active" >
<span class='glowing-txt'>G<span class='faulty-letter'>E</span>NERATE</span>
</button>
</div>
The script does not work and the browser console writes errors: ```js
Uncaught TypeError: Cannot read properties of null (reading 'style')
at draw (scripts.js:103:9)
at timer (zone.js:2402:41)
at _ZoneDelegate.invokeTask (zone.js:403:31)
at _Zone.runTask (zone.js:174:47)
at invokeTask (zone.js:484:34)
at ZoneTask.invoke (zone.js:473:48)
at data.args.<computed> (zone.js:2382:32)
Many times per second.