Site
- add scroll function
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
|
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2024/09/13 16:20:58 by tomoron #+# #+# #
|
# Created: 2024/09/13 16:20:58 by tomoron #+# #+# #
|
||||||
# Updated: 2024/09/17 15:18:09 by tomoron ### ########.fr #
|
# Updated: 2024/09/17 15:33:06 by edbernar ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ class Game:
|
|||||||
self.end = False
|
self.end = False
|
||||||
|
|
||||||
self.p1Pos = {"pos":0, "up": False}
|
self.p1Pos = {"pos":0, "up": False}
|
||||||
self.p1Pos = {"pos":0, "up": False}
|
self.p2Pos = {"pos":0, "up": False}
|
||||||
|
|
||||||
self.ballPos = {"pos":(0, 0), "up": False}
|
self.ballPos = {"pos":(0, 0), "up": False}
|
||||||
self.speed = Game.startSpeed
|
self.speed = Game.startSpeed
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
<div id="topBar">
|
<div id="topBar">
|
||||||
<h1>PTME</h1>
|
<h1>PTME</h1>
|
||||||
<div id="topButton">
|
<div id="topButton">
|
||||||
<p onclick="scrollToSection()">HOME</p>
|
<p>HOME</p>
|
||||||
<p>PROJECT</p>
|
<p id="AAAAAAA">PROJECT</p>
|
||||||
<p>AUTHORS</p>
|
<p>AUTHORS</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="loginButton">
|
<div id="loginButton">
|
||||||
@ -80,7 +80,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<section class="homeSection">
|
<section class="homeSection">
|
||||||
</section>
|
</section>
|
||||||
<section class="homeSection relative">
|
<section class="homeSection relative" id="QWERTYUIOP">
|
||||||
<img id="firstBall" src="/static/img/homePage/ball3D2.png">
|
<img id="firstBall" src="/static/img/homePage/ball3D2.png">
|
||||||
<img id="secondBall" src="/static/img/homePage/ball3D3.png">
|
<img id="secondBall" src="/static/img/homePage/ball3D3.png">
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* main.js :+: :+: :+: */
|
/* main.js :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: marvin <marvin@student.42.fr> +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/25 00:02:19 by edbernar #+# #+# */
|
/* Created: 2024/08/25 00:02:19 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/09/17 13:06:30 by marvin ### ########.fr */
|
/* Updated: 2024/09/17 16:43:50 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ class HomePage
|
|||||||
Login.create();
|
Login.create();
|
||||||
LiveChat.create();
|
LiveChat.create();
|
||||||
window.addEventListener('scroll', scrool);
|
window.addEventListener('scroll', scrool);
|
||||||
window.addEventListener('bScroll', scrollToSection)
|
document.getElementById('AAAAAAA').addEventListener('click', scrollToSection)
|
||||||
}
|
}
|
||||||
|
|
||||||
static dispose()
|
static dispose()
|
||||||
@ -31,13 +31,16 @@ class HomePage
|
|||||||
Login.dispose();
|
Login.dispose();
|
||||||
LiveChat.dispose();
|
LiveChat.dispose();
|
||||||
window.removeEventListener('scroll', scrool);
|
window.removeEventListener('scroll', scrool);
|
||||||
window.removeEventListener('bScroll', scrollToSection)
|
document.getElementById('AAAAAAA').removeEventListener('click', scrollToSection)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function scrollToSection() {
|
function scrollToSection()
|
||||||
document.querySelector('#homeSection relative').scrollIntoView({
|
{
|
||||||
behavior: 'smooth'
|
const pos = document.getElementById('QWERTYUIOP').getBoundingClientRect().top + window.scrollY;
|
||||||
|
window.scroll({
|
||||||
|
top: pos,
|
||||||
|
behavior: 'smooth'
|
||||||
});
|
});
|
||||||
console.log("CACA");
|
console.log("CACA");
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/18 00:53:53 by edbernar #+# #+# */
|
/* Created: 2024/08/18 00:53:53 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/09/17 15:04:18 by edbernar ### ########.fr */
|
/* Updated: 2024/09/17 15:38:02 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -113,10 +113,12 @@ class MultiOnlineGamePage
|
|||||||
renderer.setAnimationLoop(loop)
|
renderer.setAnimationLoop(loop)
|
||||||
sendRequest('game', {action: 1});
|
sendRequest('game', {action: 1});
|
||||||
let lastPosition = player.object.position.x;
|
let lastPosition = player.object.position.x;
|
||||||
|
let lastUp = player.isUp;
|
||||||
interval = setInterval(() => {
|
interval = setInterval(() => {
|
||||||
if (player && player.object.position.x != lastPosition)
|
if (player && player.object.position.x != lastPosition || player.isUp != lastUp)
|
||||||
{
|
{
|
||||||
lastPosition = player.object.position.x;
|
lastPosition = player.object.position.x;
|
||||||
|
lastUp = player.isUp;
|
||||||
sendRequest('game', {action: 3, pos: player.object.position.x, up: player.isUp});
|
sendRequest('game', {action: 3, pos: player.object.position.x, up: player.isUp});
|
||||||
}
|
}
|
||||||
}, 1000 / 20);
|
}, 1000 / 20);
|
||||||
@ -160,9 +162,6 @@ class MultiOnlineGamePage
|
|||||||
static opponentDisconnect()
|
static opponentDisconnect()
|
||||||
{
|
{
|
||||||
pageRenderer.changePage('lobbyPage');
|
pageRenderer.changePage('lobbyPage');
|
||||||
setTimeout(() => {
|
|
||||||
CN.new("Game", "Opponent disconnect", CN.defaultIcon.error);
|
|
||||||
}, 1000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user