Ways to resolve erratic scrolling in Vue when using v-for with dynamically added elements

Screen recording

In the video above, I demonstrate the same web application in Safari, Chrome, and Firefox.

Upon hitting start, an infinite loop creates a new tile, places it temporarily in the main array based on window.scrollY, waits for 1 second, then permanently adds the tile to the array. The current window.scrollY is continuously updated every 8ms and displayed at the top right corner of the screen.

My test involves waiting for at least 5 tiles to be added, then slowly scrolling down without releasing the mouse button for 50-100 pixels. Safari handles this smoothly, while Chrome suddenly jumps the scroll position by +200 pixels and Firefox jumps to the end of the array.

It's worth noting that disabling all transition-group animations and per-tile animations had no effect. Additionally, no usage of ScrollTo or similar methods exist in the code.

The v-for directive is implemented as follows:

<div id="tileStack">
  <transition-group name="transitionStack" tag="ul">
    <TileItem 
      v-for="tile in tileStackWithGap"
      :key="tile.key
    />
  </transition-group>
</div>

Where tileStackWithGap contains the computed array with new tiles included.

All relevant CSS rules are defined as:

html, body, ul {
  margin: 0;
  padding: 0;
}

#tileStack {
  width: 100vw;
  padding: 40.5vh 0;
}

.tileMain {
  width: 30vh;
  max-width: calc(100vw - 4vh);
  height: 15vh;
  padding: 0px;
  margin: 2vh auto;
  border-radius: 3vh;
}

.tilePreview {
  width: 24vh;
  max-width: calc(80vw - 3.2vh);
  height: 12vh;
  border-radius: 2.4vh;
}

The tilePreview class is applied to the "temporary" tiles.

What might be causing this unexpected behavior and how can it be resolved?

Answer №1

Upon further investigation, it seems that the issue stemmed from scroll anchoring, which ended up having the opposite effect in my situation. This problem can be resolved by disabling it using overflow-anchor: none

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

Retrieving JavaScript array data following a page reload

I am facing an issue with updating an array dynamically in my C# server-side code and then utilizing the updated data in a JQuery function on my webpage. When the page first loads, the array is filled with some default values by C#. However, when a user ma ...

Facing the issue of not being able to overwrite the default initialized data (variable) in VUE.JS 2 when using the

Situation I created a generic modal component that uses a global bus (empty VUE instance) to communicate with the modal component from any other component that utilizes it. Problem In the Mounted() or Created() hook for the Modal.VUE component, I am att ...

Issues are occurring with the @font-face css for the Futura Bk BT Bok.ttf font file

Is there a way to incorporate the 'Futura Bk BT Bok.ttf' font into my website using the CSS @font-face rule? Here is a snippet of my current CSS: @font-face { font-family: abcd; src:url('Futura Bk BT Bok.ttf') format('true ...

Encountering the issue of receiving type [object object] in file content rather than a blob when downloading a file with Angular 7

When using Angular 7, I encountered an issue while calling an API with the GET method and attempting to download a file using the 'saveAs' function from the fileSaver library. After retrieving the filename from the response header, I found that ...

Sending selected radio button values to a MySQL query

I'm struggling with implementing radio buttons to control my MySQL query. It seems like I've made some mistakes in setting it up or there are minor errors present. (1) The displayed value of the radio buttons is set as the result of query A usin ...

Unable to determine the data type of the JSON object during the

I'm having trouble reading an Object type of json... Here is the json I'm working with: body: { "111": { "name": "name1", "status": 10000 }, "222": { "name": "name2", "status": 20000 }, "333": ...

The values in the Jquery drop-down menu are not updating when selected, causing the button link to display the

Struggling to decode my code here. Every time a user chooses a corporation from the dropdown, it displays the name, phone number, email, and cc correctly but the "mailto:" link button is missing. I want to add a button that generates a mailto link using th ...

`Grab a portion of text from a different contenteditable div using code`

<div id="leftdiv" style="float:left;display:inline-block;height:100px;font-family:Helvetica;font-size:14px;width:300px;border:1px solid red;" contenteditable> <div> Unique first text </div> <div> Unique s ...

How to capture a change event in a dynamically loaded element using JQuery

I am facing an issue with dynamically added rows in my table. Each row contains a select option, and I need to trigger an action when the select is changed. However, since the rows are loaded after the page load, my function does not work as expected. < ...

What is the process for transforming fetch() into XML HTTP Requests?

In my code, I originally used fetch(), but for my specific situation, using XMLHttpRequest() would be more suitable. However, I am struggling to convert the code to utilize XMLHttpRequest(). This is the original fetch() code: fetch("file.wasm") ...

Initiate a timer controlled by the parent component in a Vue 3 application

Is there a way to trigger a method in a child component from its parent in Vue 3 without using Event Bus? Let's take the example of a timer trigger method: methods: { startTimer: function () { this.timer = setInterval(() => this.countdow ...

Assign values to variables in a JavaScript file using node.js

My tech stack includes node.js, express.js, and either pug or jade. Within my server, I inject a variable called pageId into a view. In the pug view, I utilize this variable using the following script: script. document.addEventListener('DOMConten ...

Issue loading ASP.NET MVC in IE7

Encountering an issue with Internet Explorer 7 while using ASP.NET MVC 3. The result page appears as follows: <button type="button" onclick=" ShowOperation('/Page/Box/ShowOperation/CreateBox', '') ">... The error message (specif ...

Guide to implementing a dynamic v-model for input fields in Vue 2 and assigning values to this v-model

I've developed a unique component that generates dynamic input fields. One of the props it utilizes is called "fields." fields: [ { label: 'Question Text', placeholder: 'Enter Text', ...

Vue CLI Axios mishandling array indexes in request handling

const sentence = this.colocation[0][i].examples; sentence.forEach((item,index) => { var colAction = this.colocation[0][i].examples[index]; const strippedString = colAction.replace(/(<([^>]+)>)/gi, "" ...

AJAX error encountered: TypeError - the properties 'arguments', 'callee', and 'caller' are inaccessible in the current context

While conducting an API call on a particular system, I encountered an error. Interestingly, I am able to obtain a response using curl and Postman with the same URL; however, Safari throws this error when employing Angular's $http.get() method. The is ...

Error message "Assignment operation cannot occur on the left side" occurs when attempting to use the NOT operator

Currently, I have this function in use: $scope.myFunction = function(indexParent, childrenLength) { // close all inner accordion tabs for(i=0; i < childrenLength; i++) { !$scope.lettersandnumbers[indexParent].things[i].open = $scope.le ...

Tips for ensuring the directive stays current with changes to the parent scope variable

Example: <div ng-show="{{ display }}"> ... </div> angular.module('mymodule').directive('mydirective', [ function () { return { scope: { display: '=' }, ... }; ...

How to toggle the visibility of a div on click using React hooks

I am looking to achieve a similar effect as shown in the images linked below. Click on a div to make it disappear, and then reappear the previously disappeared div. Check out the before click image (before onclick) and after click image (after oncilck). B ...

Is it possible to update Vuex data without making an API request?

Running a PHP backend and already having the necessary data that I would like to set within my Vuex store presents an interesting challenge. Typically, if the data is readily available and only needs to be passed along to a component, I would encode it usi ...