Javascript replace/append statement

I’m looking for help with the following. I need to add a block at the end of a line if it does not already exist. The line could be in any of the following formats (M could be either 3 or 4, S could be and number):

M4S10000

S10000M4

M4 S10000

S10000 M4

I want to add the string “G4 P1” to the end of the line as long as it doesn’t already exist

M4S10000 – Append to become M4S10000 G4 P1
M4S10000 G4 P1 – Ignore the line and move on

Original line left out a few conditions:

gcode = gcode.replace(/(S[0-9]* M[3-4])|(M[3-4] S[0-9]*)/g, ‘$& G4 P1’);

I’m looking to expand it to cover with or without a space between S and M blocks

gcode = gcode.replace(/(S[0-9]* M[3-4])|(M[3-4] S[0-9])|
(M[3-4]S[0-9]
|S[0-9]*M[3-4])/g, ‘$& G4 P1’);

Next I would like to do is make sure we don’t add “G4 P1” if it’s already there

Application did not respond

i’ve been trying to code a ranked discord bot and i managed to code it but when i run the bot and try to set it up in my discord server it gives me this error saying ‘application did not respond’ can someone please help me figure this out i’m not even sure if the code will do the job but it’s my first project and i just started learning how to code so if theres anything wrong feel free to tell me

const Discord = require('discord.js');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const client = new Discord.Client({
  intents: [
    Discord.GatewayIntentBits.Guilds,
    Discord.GatewayIntentBits.GuildMessages
  ]
});

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}`);
});

const Enmap = require('enmap');
const prefix = '-'; // Change this to your desired prefix
const queues = new Enmap({ name: 'queues' });
const rankings = new Enmap({ name: 'rankings' });

client.on('messageCreate', async (message) => {
  if (!message.content.startsWith(prefix) || message.author.bot) return;

  const args = message.content.slice(prefix.length).split(/ +/);
  const command = args.shift().toLowerCase();

  // Command to check rank
  if (command === 'rank') {
    const playerID = message.author.id;
    const playerRank = rankings.get(playerID) || 0;
    message.reply(`Your rank is ${playerRank}`);
  }

  // New command: Setup with -sett
  if (command === '-sett') {
    try {
      const channel = await message.guild.channels.create('Queue', { type: 'GUILD_TEXT' });

      const joinButton = new Discord.MessageButton()
        .setCustomId('join_queue')
        .setLabel('Join Queue')
        .setStyle('PRIMARY');

      const leaveButton = new Discord.MessageButton()
        .setCustomId('leave_queue')
        .setLabel('Leave Queue')
        .setStyle('DANGER');

      const row = new Discord.MessageActionRow()
        .addComponents(joinButton, leaveButton);

      const queueMessage = await channel.send({ content: 'Click a button to join or leave the queue:', components: [row] });

      // Store queue message and channel id for future reference
      queues.set('queue_message', queueMessage.id);
      queues.set('queue_channel', channel.id);

      // Inform setup completion
      message.reply('Queue setup completed.');
    } catch (err) {
      console.error('Error during setup:', err);
      message.reply('There was an error during setup.');
    }
  }
});

const YOUR_BOT_TOKEN = '';
const YOUR_APPLICATION_ID = '';
const YOUR_GUILD_ID = '';

client.login(YOUR_BOT_TOKEN);

const commands = [
  {
    name: 'sett',
    description: 'Set up the queue system',
    type: 1,
  },
];

const rest = new REST({ version: '9' }).setToken(YOUR_BOT_TOKEN);

(async () => {
  try {
    console.log('Started refreshing application (/) commands.');

    await rest.put(
      Routes.applicationGuildCommands(YOUR_APPLICATION_ID, YOUR_GUILD_ID),
      { body: commands },
    );

    console.log('Successfully reloaded application (/) commands.');
  } catch (error) {
    console.error(error);
  }
})();

I tried everything but i cant seem to find where the problem is

React Displays Symbols Instead of Accents

enter image description hereI’m facing a persistent issue in my React application where accented characters are being displayed as symbols. This problem is observable even in the developer tools, where the accented characters are already appearing as symbols. I’m currently using the latest version of Microsoft Visual Studio

Strucutre of some of my components:

App.js:

javascript
Copy code
import React from 'react';
import './App.css';
// ... other imports

function App() {
    // ... App logic
    return (
        <div className="App">
            {/* Content involving text */}
        </div>
    );
}

export default App;

CadastroPacienteBiopsia.css:

css
Copy code
/* CSS styles showing how elements are styled */
.formulario-cadastro {
    /* styles */
}
/* ... other styles */

NeurocirurgiaDashboard.jsx:

javascript
Copy code
import React, { useState, useEffect } from 'react';
// ... other imports

function NeurocirurgiaoDashboard() {
    // Component logic
    return (
        <div className="dashboard">
            {/* Content involving text */}
        </div>
    );
}

export default NeurocirurgiaoDashboard;

Attempts Made:

Ensured that file encoding is set to UTF-8 in the editor.
Included in the HTML file.
Verified that the database and API responses are correct.

Despite these implementations, the issue with accented characters persists. The characters are displayed as symbols in the application as well as in the developer tools. This leads me to suspect the issue might be related to how React or my development environment is handling character encoding.

Could anyone suggest a solution or point out what I might be missing here? Any help or guidance would be greatly appreciated.

Thank you in advance!

MediaPipe Static Stored Video Face Landmark Detection

I have been trying to get media pipe to detect face landmarks in a static(stored) video but all the online guides and tutorials use live camera feed. It is easy in python but I have to do it in JavaScript.

I found these 2 guides to be most relevant but both are using live camera feed.

https://medium.com/@mamikonyanmichael/what-is-media-pipe-and-how-to-use-it-in-react-53ff418e5a68

https://github.com/jays0606/mediapipe-facelandmark-demo

Any kind of help would be appreciated.

Little Background: I am making a 3D sign language avatar. For a sentence, my initial plan is to stitch different word-level videos together(not efficient but hey some progress) and then make a 3D avatar to imitate it using Ready Player Me and Mediapipe.

Prisma – Error validating datasource from docker container

So I am working on a project where I created a logger service that uses prisma to post some logs to a postgres database. The logger service is in a docker container and the postgres db is also in a contanier. Both are on a testing linux computer.

I can use DBeaver to connect to the databse and creating tables and everythign as normal.
When I spin up the logger service with node on my main computer, everything works as expected posting logs to the database in the container on the linux computer.

When I hit the logging service in a container on the linux computer, from my main computer. I get the following error:

error: Error validating datasource db: the URL must start with the protocol postgresql:// or postgres://.

For the docker file I am running the following:

FROM node:18-alpine
WORKDIR /usr/app
COPY ./ /usr/app

ARG EXPOSE_PORT=3000
ARG LOGGER_ENV="DEV"
ARG LOG_DATABASE_URL="postgresql://postgres:exmaple@localhost:5432/log"
ENV LOGGER_PORT=${EXPOSE_PORT}
ENV LOG_DATABASE_URL=${LOG_DATABASE_URL}
ENV DB_LOGGER_ENVIORMENT=${LOGGER_ENV}
RUN npm install
RUN npm uninstall prisma
RUN npm install prisma
RUN npx prisma generate
EXPOSE ${EXPOSE_PORT}
CMD ["npm", "start"]

I am using portainer and the template allows for the user of docker compose and that file looks like this:

services:
  database:
    image: postgres
    environment:
      - POSTGRES_PASSWORD= {{ DB_PASSWORD }}
      - POSTGRES_USER={{ DB_USER }}
    ports:
      - 5432:5432
    restart: always
    networks:
      - backend
  logger-service:
    environment:
      - LOG_DATABASE_URL= postgresql://{{ DB_USER }}:{{DB_PASSWORD}}@database:5432/log
      - LOGGER_PORT= {{ LOGGER_PORT }}
      - DB_LOGGER_ENVIORMENT= {{ LOGGER_ENV }}
    image: ghcr.io/bednaz98/db-logger:main
    ports:
      - {{ LOGGER_PORT }}:{{ LOGGER_PORT }}
    restart: always
    depends_on:
      - database
networks:
  backend:
    driver: bridge

When the logger service starts up, I can print that a db url string does exist in the contanier an I can print out the following when the prisma client is inialized and the string is added to the class constructor:

prisma client db string:  
- db type:  postgresql
- host ip: localhost:5432

I am using git packages to create a the docker container, and I event tried supplying a dumby db url string in the yaml env: postgresql://test:test@localhost:3000/log in hopes that maybe the prisma generated file needed it at that point. However it seems the program running in teh container can find the generate functions as expected.

Why would this not work in a container but but work running it directly though node (ts-node technically)?

I tried looking into the previous post and they did not work:

Normalizing editor and keeping sync with DOM in SlateJS

I’m trying to build a paginated editor with Slate React similar to MS Word. However, I’ve had problems trying to apply automatic page breaks.

Description of the problem

To create the pages for the editor, I came up with a custom node of type ‘page’ that has the following structure when rendered:

 <div className="page" {...attributes} >
      <div className="inner-page-container">
        {children}
      </div>
 </div>

Children are “paragraph” nodes that render like:

<p className="paragraph" {...attributes}>{children}</p>

Then, I try to normalize each of these page nodes with:

import { Transforms,Element,Node, Editor ,Text, nodes} from 'slate'
import { ReactEditor } from 'slate-react'

const emptyPage: any ={type:'page',children:[{type:'paragraph', children:[{type:'text',text:''}]}]}

function withCustomNormalize(editor: ReactEditor) {
 const { normalizeNode } = editor

 editor.normalizeNode = (entry) => {
  const [node, path] = entry

  // if(Text.isText(node)) return normalizeNode(entry)

  if (Element.isElement(node) && node.type === 'page') {
    let PageNode
    let NextPageNode
    let PageHeight
    let ChildrenHeight = 0
    try{
      PageNode = ReactEditor.toDOMNode(editor, node)
      NextPageNode = PageNode.nextSibling
      const styles = window.getComputedStyle(PageNode)
      PageHeight = PageNode.clientHeight - (parseFloat(styles.paddingTop) + parseFloat(styles.paddingBottom))
    }catch(e){
      console.log(e)
      return
    }

    const innerContainer = (PageNode.children[0] as HTMLElement)

    for (const child of innerContainer.children){
      ChildrenHeight += child.clientHeight
    }

    
    const delta = PageHeight - ChildrenHeight
    
    if (delta < 0  && NextPageNode == null){
      Transforms.liftNodes(editor)
      Transforms.splitNodes(editor)
      Transforms.wrapNodes(editor, emptyPage)
    } else if (delta < 0 && NextPageNode != null){
      try {
        Transforms.moveNodes(editor, {to: [path[0] + 1, 0]})
      } catch (e){
        return 
      }
    }
  }
  normalizeNode(entry)
}
  return editor
}

export default withCustomNormalize

The code checks if there’s overflow on the inner-container and, case positive, if there’s no “next page”, splits the selections and wraps it around a new page node, otherwise it just moves the selection to the next page. Problem is: when hitting enter on the last possible line before overflowing, another paragraph node is created below. Only when I type something in, normalization is called. The image below kind of describes what I mean.

enter image description here

For more context, pretty much the same behavior can be seen here https://github.com/usunil0/slate-paged/tree/master (where I got the core idea for most of the code)

enter image description here
(Although the last node is active as if you could type something in, as soon as you try so, normalization is called, when it should’ve been called before for this to work as expected)

I know this is due to how normalization is triggered, as mentioned here https://github.com/ianstormtaylor/slate/issues/3465

I’d like to know of any ideas/possible workarounds for this problem. How can I call normalization for all children nodes under a certain parent(as in my “page” case)?

Allow Javascript object without parens in Monaco code editor

I’m trying to allow users to enter something like the following into a monaco editor instance (in react – @monaco-editor/react):

{a: 1, b: 3 + 2}

Monaco syntax highlighting considers this a syntax error, because it would be one in a standalone js file (the curly braces would be interpreted as block curly braces).

As a workaround, users can enter the following, but it is unintuitive/annoying to need to:

({a: 1, b: 3 + 2})

Is there some way I can modify the monaco editor syntax highlighting to ignore this case or add parens in the background to convey it should be considered valid?

Module firebase not found in script

I try to do something simple, import firebase in my index.html and start analytics.

I import the code, but i have ReferenceError: firebase is not defined. Please what is wrong with my code ?

<body>

<script src="https://www.gstatic.com/firebasejs/10.7.1/firebase-app.js"></script>
<script  src="https://www.gstatic.com/firebasejs/10.7.1/firebase-analytics.js"></script>

<script>
  // Initialize Firebase with your configuration
  const firebaseConfig = {
    apiKey: "AIzaSyDMOXXXXXXXXXXXu6fMbeqU",
    authDomain: "XXXXXXXXXXXXXXXXXXXe.firebaseapp.com",
    projectId: "XXXXXXXXXXXXXXX",
    storageBucket: "XXXXXXXXXXXXXXXXXXX.appspot.com",
    messagingSenderId: "XXXXXXXXXXXXXXXXXXXXXX3370",
    appId: "1:XXXXXXXXXXXXXXXXXX:web:XXXXXXXXXXXXXXXXXXXXXXX",
    measurementId: "G-XXXXXXXXXXXXXXXX"
  };

  // Initialize Firebase
  firebase.initializeApp(firebaseConfig);

  // Initialize Firebase Analytics
  const analytics = firebase.analytics();

  // Log an event (optional)
  analytics.logEvent('star_html5_game');

  // You can start tracking events and user interactions here
</script>


</body>

Javascript filter array of objects by object property value

I’m stumped here. I am trying to filter an array of objects down to just the objects that include a certain string in one of the object properties. The array is being passed into a javascript function in NodeRed, so I’m making a few assumptions on what the formatting of the array is. This is the output of my array:
Array output
I am looking for a way to filter the array down to only the objects whose “state” starts with the “Z_” prefix. The end result is to use the last entry, as I need the most recent “Z_” state and the array is ordered by timestamp. That said, I believe I need an array of the “Z_” states to then grab the last entry of, meaning I can’t use the “find” function or similar that identifies the first match. I also expect duplicate “Z_” values within multiple objects in the array, so I can’t rely on anything looking for unique values.

It seems to me that it would be best practice to accomplish this with the proper function, rather than with an iterating loop?

In filtering the above array, I expect the result to be an array of 2 entries, the “state”: “Z_Rain” and “Z_Blues” entry.

I have tried to use array.filter which resulted in a “TypeError: X.filter is not a function”. I believe this is due to the array being an array of objects, so I tried Object.values(array) to no avail. I also tried a fair few variations of X.filter() with > / => / etc. operators.

How can check two elements have similar fontSize or not by playwright?

I have two page that have same h1 elements, but different have different fontSize.
One of them is 20px, and another is 22px.
I am looking for comparing two page visually in playwright.
At first I have written the following code for capturing initial screenshots from urls:

import { test, expect } from "@playwright/test";
import { chromium } from "@playwright/test";
const playwright = require("playwright");
test("example test", async ({ page }) => {
  const browser1 = await chromium.launch();
  const browser2 = await chromium.launch();
  const page1 = await browser1.newPage();
  const page2 = await browser2.newPage();
  await page1.goto("localhost:5500/index.html");
  await page2.goto("localhost:5501/index.html");

  await expect(page1).toHaveScreenshot();
  await expect(page2).toHaveScreenshot();
});

After capturing screenshots, I have modified and added the following code to my test code to compare screenshots of page1 with page2:

import { test, expect } from "@playwright/test";
import { chromium } from "@playwright/test";
const playwright = require("playwright");
test("example test", async ({ page }) => {
  const browser1 = await chromium.launch();
  const browser2 = await chromium.launch();
  const page1 = await browser1.newPage();
  const page2 = await browser2.newPage();
  await page1.goto("localhost:5500/index.html");
  await page2.goto("localhost:5501/index.html");
   expect(await page2.screenshot()).toMatchSnapshot("test2.png", {
     maxDiffPixels: 10,
   });

});

But, when i run the command npx playwright test, Playwright can not recognize the differences between fontSize. However, when the difference value is much larger, it can be recognized!.
How can solve this problem?

React JS App rendering white page on reloading in a chat app: How to solve?

The problem is straightforward.
I have a ‘main’ page which collects data through a form and sends that data to a ‘chat’ page.
Everything works completely fine up until I reload the chat page, which renders everything a blank white. There are no errors in the console.
The url at that point should have the username and the the chat-room’s name, which remains in the url as far as I can see, even after having reloaded the page and gotten a blank white page.

This seems to be a popular problem but none of the suggested solutions have worked for me so far. This is what I have tried:

  • changed “homepage” in package.json

  • tried the whole

    /* index.html 200

  • tried HashRouter instead of BrowserRouter, tried including basename
    for Router, tried including browserhistory

  • tried downgrading react to earlier versions

None of this has worked so far for me.Here is a live link to the site: https://cyberpunk-chat.onrender.com/

Here is the github repo: https://github.com/mohanamisra/chat-app-full-code

Here’s some relevant code anyways, just in case:

The page importing the routers:

IN App.js

import React from 'react';
import {BrowserRouter as Router, Route, Routes} from 'react-router-dom';
import Join from './components/Join/Join';
import Chat from './Chat';

const App = () => {
    return (
        <Router basename = "/">
            <Routes>
                <Route path='/' element={<Join/>}/>
                <Route path='/chat' element={<Chat/>}/>
            </Routes>
        </Router>
    );
};

export default App;

IN Chat.js

import React from 'react';
import {useState, useEffect} from 'react';
import queryString from 'query-string';
import { useNavigate } from 'react-router-dom';
import io from 'socket.io-client';
import InfoBar from "./components/InfoBar/InfoBar";
import Input from "./components/Input/Input";
import Messages from "./components/Messages/Messages";
import TextContainer from "./components/TextContainer/TextContainer";

import './Chat.css';
const ENDPOINT = 'https://cyberpunkchat.onrender.com';

let socket;

const Chat = () => {
    const navigate = useNavigate();
    const [name, setName] = useState('');
    const [room, setRoom] = useState('');
    const [messages, setMessages] = useState([]);
    const [message, setMessage] = useState('');
    const [users, setUsers] = useState('');

    useEffect(() => {
        const {name, room} = queryString.parse(window.location.search);
        socket = io(ENDPOINT, {transports:['websocket']});
        if(!name || !room) {
            console.log('I forgot...');
        }
        else {
            setName(name);
            setRoom(room);
            socket.emit('join', {name, room}, () => {
            });
        }
    }, [ENDPOINT, navigate]);

    useEffect(() => {
        socket.on('message', (message) => {
            setMessages([...messages, message]);
        })
        socket.on("roomData", ({ users }) => {
            setUsers(users);
        });
    }, [messages]);

    const sendMessage = (event) => {
        event.preventDefault();
        if(message)
            socket.emit('sendMessage', message, () => setMessage(''));
    }

    return(
        <div className = 'outerContainer'>
            <TextContainer users = {users}/>
            <div className = 'container'>
                <InfoBar room = {room}/>
                <Messages messages = {messages} name = {name}/>
                <Input message = {message} setMessage={setMessage} sendMessage={sendMessage}/>
            </div>
        </div>
    )
}

export default Chat;

I’d appreciate any help at all.

Thanks in advance!

Why does React use the concept of a Virtual DOM when modern browsers can efficiently handle DOM changes?

In traditional browsers, developers often had to directly manipulate the entire Document Object Model (DOM), triggering re-rendering or modification of the entire structure when changes occurred. However, with advancements, modern browsers can intelligently identify and manipulate only the changed parts of the DOM.

Considering this, I’m curious about the necessity of React’s Virtual DOM. Why does React continue to use the concept of a Virtual DOM when browsers are now capable of efficiently handling DOM changes? What** benefits does the Virtual DOM bring** to the table in today’s web development landscape?

I”ve been exploring React and the concept of the Virtual DOM, and I’m curious about its necessity in light of modern browsers’ capabilities to efficiently handle DOM changes. I’ve read some documentation and articles on React, but I’m still trying to grasp why the Virtual DOM is employed.

Why is my website going outside of the page when shrunk down to mobile phone view?

For some reason the content I have in my row doesn’t stop before the footer and just goes through it. I have no idea what the issue is so I’ve attached as much as I could. Any help would be greatly appreciated!

The page breaking

The page breaking with inspect on (1)

The page breaking with inspect on (2)

HTML Code

<body>
  <div class="container-fluid">
      <div class="p row">
        <div class="holder col-xl-1">
        </div>

        <div class="holder col-xl-5">
          <div id="imghold1" class="imghold">
            <img class="imgdes" src="img/index/capsule_616x353.jpg">
            <p class="des1">Forza Horzon 5
              <p class="des2">Forza Horizon 5 is a 2021 racing video game developed by Playground Games and published by Xbox Game Studios. 
                It is the fifth Forza Horizon title and twelfth main instalment in the Forza series. 
                The game is set in a fictionalised representation of Mexico.
                It was released on 9 November 2021 for Windows, Xbox One, and Xbox Series X/S.
                The game received critical acclaim and became a commercial success upon release; it launched to over ten million players in the first week, the biggest-ever launch for an Xbox Game Studios game.
              </p>
            </p>
          </div>
        </div>

        <div class="holder col-xl-5">
          <div id="imghold2" class="imghold">
            <img class="imgdes" src="img/index/Forza-Horizon-5-Starter-Cars.jpg">
            <p class="des1">Cars
              <p class="des2">Players can choose from a selection of cars; buggies, rally cars, concept cars, trucks, and road cars.
                A complete UX overhaul brings the experience in-line with modern image manipulation software. 100 new rims, hundreds of new visual upgrades, and thousands of performance upgrades have been added.
                Players can equip a car horn to any vehicle from a selection of various available standard horns, musical horns, and sound effects.
                Send and receive gifts from the community. Players can take one of their cars, apply upgrades and a paint job, and then drop it as a gift to another player.</p>
            </p>
          </div>
        </div>

        <div class="holder col-xl-1">
        </div>

        <div class="holder col-xl-1">
        </div>

        <div class="holder col-xl-5">
          <div id="imghold3" class="imghold">
            <img class="imgdes" src="img/index/dfqog5klxjf81 (1).png">
            <p class="des1">Tuning
              <p class="des2">When it comes to tuning in Horizon the most important aspect you need to understand is the concept of car types and body types.
                Car types provide a general classification of all cars in Forza and group several body types. Each car type needs a distinctive way to be setup in terms of tuning.
                Generally Horizon distinguishes between road, race, rally and off-road cars.
                Tuning gives you the ability to change the cars handling and performance to suit your needs and desires and create the perfect car for your perfect experience.
              </p>
            </p>
          </div>
        </div>

        <div class="holder col-xl-5">
          <div id="imghold4" class="imghold">
            <img class="imgdes" src="img/index/E_WBK34X0AIibQm.jpg">
            <p class="des1">Horizon Festival Mexico
              <p class="des2">The Horizon Festival Mexico is a music and motoring celebration held by Horizon within Mexico. 
                Players arrive at the festival and are greeted with the expansive landscape of Mexico, hundreds of cars to choose from, and a multitude of other racers at the festival to compete or co-operate with in events.
                The Festival Playlist is a monthly rotating selection of challenges and rewards, with each Series offering a differing set of goals for players to beat and earn rewards across all four seasons.
              </p>
            </p>
          </div>
        </div>

        <div class="holder col-xl-1">
        </div>

      </div>
<footer>
<img src="img/index/Pngtreebottom-black-shadow-overlay-gradient_7273428.jpg" id="shadow"> 
  <div id="footop">
    <img src="https://preview.redd.it/j80efhv9cdv61.png?width=640&crop=smart&auto=webp&s=04a3012da3a9c7bd7906f06a42e8f8b6719f13c3" class="footimg">
    <p class="footp">FORZA HORIZON</p>
  </div>

  <div class="breaker"></div>

  <div class="container-fluid">
    <div class="row">
      <div class="col-lg-4"></div>
      <div class="footlinks col-lg-1 col-3">
        <a class="afoot" href="index.html">Home</a>
      </div>
      <div class="footlinks col-lg-1 col-3">
        <a id="acars" class="afoot" href="cars.html">Cars</a>
      </div>
      <div class="footlinks col-lg-1 col-3">
        <a class="afoot" href="upgrades.html">Upgrades</a>
      </div>
      <div class="footlinks col-lg-1 col-3">
        <a id="aabout" class="afoot" href="about.html">About</a>
      </div>
      <div class="col-lg-4"></div>
    </div>
  </div>

  <div class="breaker"></div>

  <div class="icons">
    <a class="aif" href="https://www.tiktok.com/@forzahorizon" target="_blank">
      <i class="if fa-brands fa-tiktok"></i>
    </a>
    <a class="aif" href="https://www.facebook.com/ForzaHorizon/" target="_blank">
      <i class="if fa-brands fa-facebook-f"></i>
    </a>
    <a class="aif" href="https://www.instagram.com/forzahorizonofficial/" target="_blank">
      <i class="if fa-brands fa-instagram"></i>
    </a>
    <a class="aif" href="https://twitter.com/ForzaHorizon" target="_blank">
      <i class="if fa-brands fa-twitter"></i>
    </a>
    <a class="aif" href="https://www.youtube.com/channel/UCydtMNspoPAlqBjFSGnigSw" target="_blank">
      <i class="if fa-brands fa-youtube"></i>
    </a>
  </div>
</footer>
</body>

CSS Code

.woroad {
    transform-style: preserve-3d;
    height: fit-content;
    width: 99.1vw;
    background-image: url('img/index/lines-traffic-paved-roads-background.jpg');
    background-position: center center;
    background-repeat: no-repeat;
    background-size: cover;

}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background-color: rgb(0, 0, 0, 0);
}

.p {
    color: #fff;
    height: fit-content;
    flex: 1 1 auto;
    z-index: -1;
    margin-top: 0;

}

.holder {
    padding: 0;
    margin: 0;
    height: fit-content;
}

.imghold {
    margin-top: 0%;
    margin-left: 15%;
    margin-right: 17%;
    margin-bottom: 0%;
    overflow: hidden;
    border-bottom-right-radius: 10%;
    border-bottom-left-radius: 1%;
    background-color: #fff;
    height: fit-content;
}

#imghold4 {
    margin-bottom: 10vw;
}

.imgdes {
    margin-left: 4%;
    margin-top: 4%;
    width: 92%;
    border-radius: 5%;
}

.des1 {
    color: #de2b73;
    margin-left: 7%;
    margin-right: 7%;
    margin-top: 4%;
    font-size: 37px;
    font-weight: 900;
}

.des2 {
    color: #000;
    font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
    font-size: 19px;
    margin-left: 7%;
    margin-right: 7%;
}

.hidediv {
    opacity: 0;
    animation: smooth-disappear 1s ease forwards;
}

.showdiv {
    opacity:1;
    animation: smooth-appear 1s ease forwards;
}



@keyframes smooth-appear {
    from {
        margin-top: 50%;
    }
    to{
      margin-top: 20%;
      opacity:1;
    }
}

@keyframes smooth-disappear {
    from {
        margin-top: 20%;
        opacity: 1;
    }
    to{
      margin-top: 50%;
    }
}

JS Code

myID = document.getElementById("imghold1");
myID2 = document.getElementById("imghold2");
myID3 = document.getElementById("imghold3");
myID4 = document.getElementById("imghold4");

var myScrollFunc = function () {
  var y = window.scrollY;
  if (y >= window.innerHeight * 0.4) {
    myID.className = "imghold showdiv"
    myID2.className = "imghold showdiv"
  } else {
    myID.className = "imghold hidediv"
    myID2.className = "imghold hidediv"
  }
  if (y >= window.innerHeight * 1.2) {
    myID3.className = "imghold showdiv"
    myID4.className = "imghold showdiv"
  } else {
    myID3.className = "imghold hidediv"
    myID4.className = "imghold hidediv"
  }
}

window.addEventListener("scroll", myScrollFunc);