88 lines
2.6 KiB
JavaScript
88 lines
2.6 KiB
JavaScript
function verificarAmbiente() {
|
|
var main = document.getElementById("entrada_1");
|
|
const tela_laod = document.getElementById('entrada_2');
|
|
let elemento_1;
|
|
let elemento_2;
|
|
|
|
if (main.innerHTML.trim() === "") {
|
|
elemento_1 = 'Estamos carregando sua página';
|
|
} else {
|
|
elemento_1 = 'Algo foi encontrado mas estamos preparando';
|
|
}
|
|
|
|
elemento_2 = '<canvas id="animationCanvas"></canvas>';
|
|
tela_laod.innerHTML = '<div class="teste"><h1>' + elemento_1 + '</h1>' + elemento_2 + '</div>';
|
|
|
|
// Inicia a animação após configurar o canvas
|
|
iniciarAnimacao();
|
|
|
|
// Inicia a contagem para limpar a tela após 3 segundos
|
|
finalizar();
|
|
}
|
|
|
|
function finalizar() {
|
|
const tela_laod = document.getElementById('entrada_2');
|
|
setTimeout(() => {
|
|
tela_laod.innerHTML = '';
|
|
}, 3000);
|
|
}
|
|
|
|
function iniciarAnimacao() {
|
|
const canvas = document.getElementById('animationCanvas');
|
|
const ctx = canvas.getContext('2d');
|
|
canvas.width = window.innerWidth;
|
|
canvas.height = window.innerHeight;
|
|
|
|
const circle = {
|
|
centerX: canvas.width / 2,
|
|
centerY: canvas.height / 2,
|
|
radius: 150,
|
|
rotationSpeed: 0.10,
|
|
angle: 0,
|
|
linePath: [],
|
|
maxPathLength: 350
|
|
};
|
|
|
|
function drawCircularPath() {
|
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
const pathX = circle.centerX + circle.radius * Math.cos(circle.angle);
|
|
const pathY = circle.centerY + circle.radius * Math.sin(circle.angle);
|
|
circle.linePath.push({ x: pathX, y: pathY });
|
|
|
|
ctx.beginPath();
|
|
for (let i = 0; i < circle.linePath.length - 1; i++) {
|
|
ctx.moveTo(circle.linePath[i].x, circle.linePath[i].y);
|
|
ctx.lineTo(circle.linePath[i + 1].x, circle.linePath[i + 1].y);
|
|
}
|
|
ctx.strokeStyle = '#22c0a3';
|
|
ctx.lineWidth = 10;
|
|
ctx.stroke();
|
|
|
|
if (circle.linePath.length > circle.maxPathLength) {
|
|
circle.linePath.shift();
|
|
if (circle.angle >= Math.PI * 2) {
|
|
circle.angle = 0;
|
|
circle.linePath = [];
|
|
}
|
|
}
|
|
}
|
|
|
|
function animate() {
|
|
circle.angle += circle.rotationSpeed;
|
|
drawCircularPath();
|
|
requestAnimationFrame(animate);
|
|
}
|
|
|
|
animate();
|
|
|
|
window.addEventListener('resize', () => {
|
|
canvas.width = window.innerWidth;
|
|
canvas.height = window.innerHeight;
|
|
circle.centerX = canvas.width / 2;
|
|
circle.centerY = canvas.height / 2;
|
|
});
|
|
}
|
|
|
|
// Executa verificarAmbiente apenas uma vez após o carregamento total da página
|
|
window.addEventListener('load', verificarAmbiente);
|