Site
- add scroll function
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# 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.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.speed = Game.startSpeed
|
||||
|
@ -3,8 +3,8 @@
|
||||
<div id="topBar">
|
||||
<h1>PTME</h1>
|
||||
<div id="topButton">
|
||||
<p onclick="scrollToSection()">HOME</p>
|
||||
<p>PROJECT</p>
|
||||
<p>HOME</p>
|
||||
<p id="AAAAAAA">PROJECT</p>
|
||||
<p>AUTHORS</p>
|
||||
</div>
|
||||
<div id="loginButton">
|
||||
@ -80,7 +80,7 @@
|
||||
</div>
|
||||
<section class="homeSection">
|
||||
</section>
|
||||
<section class="homeSection relative">
|
||||
<section class="homeSection relative" id="QWERTYUIOP">
|
||||
<img id="firstBall" src="/static/img/homePage/ball3D2.png">
|
||||
<img id="secondBall" src="/static/img/homePage/ball3D3.png">
|
||||
<div class="relative">
|
||||
|
@ -3,10 +3,10 @@
|
||||
/* ::: :::::::: */
|
||||
/* main.js :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: marvin <marvin@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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();
|
||||
LiveChat.create();
|
||||
window.addEventListener('scroll', scrool);
|
||||
window.addEventListener('bScroll', scrollToSection)
|
||||
document.getElementById('AAAAAAA').addEventListener('click', scrollToSection)
|
||||
}
|
||||
|
||||
static dispose()
|
||||
@ -31,12 +31,15 @@ class HomePage
|
||||
Login.dispose();
|
||||
LiveChat.dispose();
|
||||
window.removeEventListener('scroll', scrool);
|
||||
window.removeEventListener('bScroll', scrollToSection)
|
||||
document.getElementById('AAAAAAA').removeEventListener('click', scrollToSection)
|
||||
}
|
||||
};
|
||||
|
||||
function scrollToSection() {
|
||||
document.querySelector('#homeSection relative').scrollIntoView({
|
||||
function scrollToSection()
|
||||
{
|
||||
const pos = document.getElementById('QWERTYUIOP').getBoundingClientRect().top + window.scrollY;
|
||||
window.scroll({
|
||||
top: pos,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
console.log("CACA");
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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)
|
||||
sendRequest('game', {action: 1});
|
||||
let lastPosition = player.object.position.x;
|
||||
let lastUp = player.isUp;
|
||||
interval = setInterval(() => {
|
||||
if (player && player.object.position.x != lastPosition)
|
||||
if (player && player.object.position.x != lastPosition || player.isUp != lastUp)
|
||||
{
|
||||
lastPosition = player.object.position.x;
|
||||
lastUp = player.isUp;
|
||||
sendRequest('game', {action: 3, pos: player.object.position.x, up: player.isUp});
|
||||
}
|
||||
}, 1000 / 20);
|
||||
@ -160,9 +162,6 @@ class MultiOnlineGamePage
|
||||
static opponentDisconnect()
|
||||
{
|
||||
pageRenderer.changePage('lobbyPage');
|
||||
setTimeout(() => {
|
||||
CN.new("Game", "Opponent disconnect", CN.defaultIcon.error);
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user