Is there a way to stabilize a section or content that bounces as I scroll?

Whenever I scroll up or down, there is a section on my page where I have implemented scroll magic. However, as I scroll through this section, it starts to jump until it reaches the position where I want it to be with transform:translateY(0).

I am unsure how to fix this issue. Could it be related to the transition or something else?

Has anyone encountered a similar problem before?

$(document).ready(function() {

  // Initializing ScrollMagic
  var controller = new ScrollMagic.Controller();

  // Creating a scene
  var ourScene = new ScrollMagic.Scene({
      triggerElement: '.section__students'
    })
    .setClassToggle('.section__students', 'fade-in') 
    .addIndicators({
      name: 'fade scene',
      colorTrigger: 'transparent',
      indent: 200,
      colorStart: 'transparent'
    }) 
    .addTo(controller);
});
.students-main {
  width: 100%;
  height: auto;
  text-align: center;
  opacity: 0;
  transform: translateY(-350px);
  transition: all 1s ease-out;
}

.section__students.fade-in {
  opacity: 1;
  transform: translateY(0);
}

.carousel {
  position: relative;
  margin: 0 auto;
}

.carousel__button {
  position: absolute;
  top: 45%;
  transform: translateY(-45%);
  background: transparent;
  border: 0;
}

.carousel__button:focus {
  outline: 0;
}

.carousel__button--left {
  left: 3.5rem;
  z-index: 1;
}

.carousel__button--right {
  right: 3.5rem;
}

.arrow-left-students {
  font-size: 3rem;
}

.arrow-left-students:hover {
  color: $color-primary;
}

.arrow-right-students {
  font-size: 3rem;
}

.arrow-right-students:hover {
  color: $color-primary;
}

.carousel__nav {
  display: flex;
  justify-content: center;
  padding: 3rem 0;
}

.carousel__indicator {
  border: 0;
  border-radius: 50%;
  width: 1.6rem;
  height: 1.6rem;
  background: $color-gray-dark-2;
  margin: 0 1.2rem;
}

.carousel__indicator:focus {
  outline: 0;
}

section .students-h1 {
  text-align: center;
  text-transform: uppercase;
  position: absolute;
  top: 10%;
  left: 50%;
  transform: translate(-50%, -140px);
}

.students-h1::after {
  content: '';
  width: 10rem;
  height: .8rem;
  background-color: $color-primary-light;
  position: absolute;
  bottom: -24rem;
  top: 70%;
  left: 50%;
  transform: translate(-50%, 30px);
  border-radius: 2rem;
}

.wrap-students {
  display: inline-block;
  justify-content: center;
  align-items: center;
  margin: 0 3rem;
  flex-direction: column;
  height: 30rem;
  width: 30rem;
  background-color: $color-grey-light-1;
  border-radius: 3rem;
}

.wrap-students:hover {
  box-shadow: -1px 3px 20px 3px $color-primary-light;
  transform: translateY(-10%);
  transition: all .5s;
}

.students {
  padding: 2.5rem 6rem;
}

.students .students-name {
  color: $color-gray-dark-2;
  padding-top: 1rem;
}

.students .students-description {
  margin-top: .5rem;
  font-style: italic;
  font-family: "lato", sans-serif;
  font-size: 1.6rem;
}

.wrap-students .students .students-img {
  border-radius: 50%;
  width: 16rem;
  height: 16rem;
  object-fit: cover;
  object-position: 50% 10%;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/ScrollMagic.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/debug.addIndicators.min.js"></script>
<section class="section__students students-main">
  <div id="parallax__carousel" class="carousel">

    <button class="carousel__button carousel__button--left">
                    <i class="fas fa-chevron-left arrow-left-students"></i>
    </button>


    <h1 class="students-h1">Students</h1>

    <div class="wrap-students">
      <div class="students">
        <img class="students-img" src="/img/student1.jpg" alt="student-image">
        <h2 class="students-name">Nick Harrison</h2>
        <p class="students-description">Lorem ipsum</p>
      </div>
    </div>

    <div class="wrap-students">
      <div class="students">
        <img class="students-img" src="/img/student3.jpg" alt="student-image">
        <h2 class="students-name">Nick Harrison</h2>
        <p class="students-description">Lorem ipsum</p>
      </div>
    </div>

    <div class="wrap-students">
      <div class="students">
        <img class="students-img" src="/img/student1.jpg" alt="student-image">
        <h2 class="students-name">Nick Harrison</h2>
        <p class="students-description">Lorem ipsum</p>
      </div>
    </div>

    <div class="wrap-students">
      <div class="students">
        <img class="students-img" src="/img/student3.jpg" alt="student-image">
        <h2 class="students-name">Nick Harrison</h2>
        <p class="students-description">Lorem ipsum</p>
      </div>
    </div>

    <button class="carousel__button carousel__button--right">
                    <i class="fas fa-chevron-right arrow-right-students"></i>
                </button>

    <div class="carousel__nav">
      <button class="carousel__indicator"></button>
      <button class="carousel__indicator"></button>
      <button class="carousel__indicator"></button>
    </div>

  </div>

</section>

Answer №1

The issue arises from the CSS implementation.

It is recommended to target the parent element's hover selector when transitioning element position on hover.

Check out this functioning EXAMPLE

.parent-container .child-element {
  transition: all .5s;
}

.parent-container:hover .child-element { 
  transform: translateY(-10%);
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Angular is failing to retrieve data from FS.readFile using promises

My goal is to utilize an Angular service to decide whether to call fs.readFile or fs.writeFile based on the button pressed, in order to explore the interaction between node and angular promises. Although I have managed to read and write files, I am facing ...

Trouble with event.preventDefault functionality

This snippet of code I'm working on is pretty basic, nothing too intricate. $("input#send").submit(function(event){ event.preventDefault(); $.ajax({ type: 'POST', url: add.php, data: data, succe ...

Adding a new column to a table that includes a span element within the td element

I am attempting to add a table column to a table row using the code below: var row2 = $("<tr class='header' />").attr("id", "SiteRow"); row2.append($("<td id='FirstRowSite'><span><img id='Plus' s ...

Is there a way to calculate the total of three input values and display it within a span using either JavaScript or jQuery?

I have a unique challenge where I need to only deal with positive values as input. var input = $('[name="1"],[name="2"],[name="3"]'), input1 = $('[name="1"]'), input2 = $('[name="2"]'), input3 = $('[name=" ...

Stopping React component click event from bubbling up to document

How do I prevent a click event in a React component from bubbling up to the document? There seems to be an issue that needs fixing! Let's see if we can resolve it on our own. I have a box component with a click event listener, and some link compone ...

Tips for preventing the sidebar from extending beyond the footer

I am facing an issue with my sidebar that follows as I scroll. How can I make it stop following when it reaches the footer? Here's what I have attempted so far: $(function() { var floatPosition = parseInt($("#left_menu").css('top')); ...

Error encountered while trying to send an array list using the $.ajax function in jQuery

My web API expects JSON data in the following format (input parameter) { "districtID": "string", "legendIDs": ["string","string"] } Below is the JavaScript code I am using to build the request: var cityDistrictId = 'fb7b7ecd-f8df-4591-89de-0c9d ...

Is it possible to center an anchor link in React JS using Webpack, Sass, and Bootstrap 4?

Recently, I started delving into React JS and Webpack but encountered a perplexing issue. My goal is simple - to center an anchor link on the screen. However, despite trying various methods like inspecting the element, removing inherited styles, setting wi ...

Animated smooth updates in d3 line graphs are the key to creating dynamic and

I'm attempting to modify an example of Animated Line Graphs from: http://bl.ocks.org/benjchristensen/1148374 <div id="graph1" class="aGraph" style="width:600px; height:60px;"></div> <script> function draw(id, width, height, upd ...

What is the best way to set conditions for document side script?

I'm struggling to disable the horizontal scroll when the viewport width is 480px or less. The script that controls the scroll behavior on my website looks like this: <script> $(function () { $("#wrapper").wrapInner("< ...

Drag near the bottom of a droppable DIV to scroll inside

Within a scrollable div, I have multiple draggable divs. However, when I drag them into another scrollable div (the droppable zone), only the page scrolls and not the droppable div itself. How can I make it so that only the droppable div scrolls while drag ...

Instantiate a fresh Date object in JavaScript by passing in my specific parameter

Check out this code snippet: $(function () { var timestamp = 1443563590; //Tue, 29 Sep 2015 21:53:10 GMT var today2 = moment.unix(timestamp).tz('America/New_York').toString(); alert(today2); //var dateinNewYork = new Date(wh ...

Tips for navigating upwards to a specific element and successfully clicking on it in Selenium

I am facing a situation where the system needs to scroll upwards to reach the web element located in the left panel of the page and then click on it to proceed with other operations. I have attempted various methods but none seem to be effective. Can anyon ...

The bottom border of the HTML header does not properly wrap around the Table of Contents (ToC), although the text within the header does. What steps

I have created a Table of Content (ToC) using a Div element and styled it with the following HTML and CSS: h3.articletitle { font-weight: bold; font-size: 30px; border-bottom: 1px solid #4F120B; } h4.articlesubtitle { font-weight: bold; ...

Using React's useEffect to implement a mousedown event listener

I created a modal that automatically closes when the user clicks outside of it. method one - involves passing isModalOpened to update the state only if the modal is currently open. const [isModalOpened, toggleModal] = useState(false); const ref = useRef(n ...

Retrieve a value using the jQuery each() method

Hello, I am a beginner in JavaScript and I need help with extracting values from JSON and adding them to an array. My goal is to be able to parse this array using another function later on. However, I'm struggling with returning the array after adding ...

Setting a CSS Variable with the Help of jQuery

I need help with changing the background color of a specific .div element when it is clicked on. I want the color to be a variable that can be changed by the user, and this change should occur when the document is ready. Currently, I am using a CSS variab ...

Storing data as a JSON string in a JavaScript object and saving it to

Have you ever wondered why the cart object is saved as "cart" in the local storage instead of being an actual object? This discrepancy is causing the cart not to display correctly. This issue arose after deploying the website on Vercel. Storing "cart" as ...

Utilize Node.js v16 for the execution of chaincode operations

Currently, I am executing JavaScript/TypeScript chaincode from fabric-samples (asset-transfer-basic/chaincode-javascript) and my requirement is to switch the Node.js version from 12 to 16. I suspect that the hyperledger/fabric-nodeenv image is specifying ...

Conceal image and substitute with a different image using JavaScript

My query pertains to JavaScript: how can I create an effect where clicking the jump-down button opens a text box and causes the button to change direction and rotate? I am considering using two photos - one hides when the jump-down button is clicked, and ...