The Swiper slider will activate only upon resizing the window

I am facing an issue with displaying a horizontal timeline that can be scrolled. Currently, I am only able to scroll the timeline when I resize the window page, and I cannot figure out why this is happening. I believe my code is correct, but I want the timeline to be scrollable without needing to resize the window. Is there a solution to fix this problem? Below is the code snippet for the swiper component.

<!--JAVASCRIPT CODE.-->
<
script src = "https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c4b2b1a184f6eaf2eaf4">[email protected]</a>" > < /script> <
  script src = "https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.1/js/swiper.min.js"
integrity = "sha256-4sETKhh3aSyi6NRiA+qunPaTawqSMDQca/xLWu27Hg4="
crossorigin = "anonymous" > < /script> <
  script >
  const data = [];

function dataFunction(dataTimeLine) {
  for (var key in dataTimeLine) {
    var value = dataTimeLine[key];
    for (var i = 0; i < value.length; i++) {
      data.push({
        dateLabel: key,
        title: value[i]
      });
    }
  }
}


// Implementing the functionality for the timeline 
new Vue({
  el: "#app",
  data: {
    steps: data
  },
  mounted() {

    var swiper = new Swiper(".swiper-container", {
      slidesPerView: 3,
      spaceBetween: 30,
      pagination: {
        el: ".swiper-pagination",
        clickable: true
      },
      navigation: {
        nextEl: ".next-slide",
        prevEl: ".prev-slide"
      }
    });
  }
}); 
</script>

Answer №1

If you want to initiate an update manually, you can try this:

 let slider = new Swiper(/* [...] */);
 slider.refresh();

Executing this code snippet should produce a similar result to resizing the element.

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

Obtain the HTTP response status code within a middleware function

I am currently developing an application where I want to create a custom logging system for every request made. For each request, I want to log the timestamp, method, route, and the response code sent to the client. Here is the code I have at the moment: ...

Enhancing Bootstrap modals with dynamic content and integrating Ajax for dynamic data retrieval in Laravel

I am facing some challenges while coding in Laravel, specifically with passing data to a modal (using the Bootstrap framework) and sending data to an Ajax post request. I have an array of items with an 'id', a 'name', and 'content& ...

Executing the Javascript function specified above upon the page being loaded

I'm fairly new to JavaScript, so please bear with me. I've got a JavaScript function on my page: <script type="text/javascript"> Sys.debug = true; var popup; Sys.require(Sys.components.popup, function () { popup = Sys.c ...

What is the process for installing a previous release of React?

Wondering how to set up an outdated version of React? Take a look at this snippet from my package.json file: "react": "^18.12.0", ...

Implementing dynamic element selection with jQuery: combining onClick and onChange events

I am looking to update the appearance of the arrow on a select option. By default, it is styled as caret-down. When a user clicks in the input area, I want to change the style to caret-up. If the select option has been changed or no action has been taken, ...

The premature reveal of the back side in the Kendo UI flip effect on Internet Explorer

Currently, I am in the process of creating a BI dashboard for a business application using JavaScript Kendo UI version v2014.1.416. Unfortunately, I have encountered an issue with certain visuals while testing on IE11. I must mention that due to practical ...

Retrieve the overall number of Formik errors for a specific field array

In the given Yup validation setup below, there is a nested Formik FieldArray: parentLevel: Yup.array().of( Yup.object({ childrenLevel: Yup.array().of( Yup.object({ childName: Yup.string().required('Name is required') ...

Ways to integrate npm dependencies into your Cordova plugin

Currently working on implementing a Cordova plugin called core-cordova found in this repository. This particular plugin has a dependency on another NPM package. The issue arises after installing the plugin in my app using: $ cordova plugin add @aerogears ...

Code error detected on basic webpage

I've been experimenting with my local storage and have encountered a strange issue. The code example that I had previously tested successfully is now not working, and I can't figure out what went wrong. Check out this link for additional informa ...

Tips for refreshing the ion-page following a pop() action in Ionic 2

On my website, I have a total of 2 pages - Page1 and Page2. During navigation from Page2 back to Page1, I use the method this.nav.pop() to close Page2 and return to Page1. However, I am looking for a way to refresh Page1 after returning to it. Any help ...

Selection of dropdown option is necessary

Hey there, I'm working on a dropdown feature and need to ensure that an option is always selected by the user. To achieve this, I'm looking to implement client-side validation for a required field. <b-dropdown id="clientData" ...

Align Button to the Right Within a Div Container

Could someone help me figure out how to align a label to the left and a button to the right within a div tag? Currently, my label aligns perfectly but my button is not aligning correctly and may even be outside of the div tag. Any assistance is appreciated ...

Tips for reducing image file size using ImageMinimizerWebpackPlugin in Next.js (webpack 5)

When attempting to use this plugin for image compression, I am encountering an issue where the build process completes successfully, but the images remain uncompressed. As a beginner with webpack, I'm unsure of what might be causing this problem. Cou ...

The issue with Axios formData containing an image results in an empty array being sent

I am facing an issue with the token authentication while trying to make a put request to my profile route in the backend. Despite passing the token through a header, I am receiving an error indicating that an empty formData is being sent when logging the r ...

Images flicker as they transition

Within my HTML body, I have the following: <a id="Hal9000"> In addition, there is a function included: function Hal(MSG){ document.getElementById("Hal9000").innerHTML = "<img src=\"+preloadImage("HAL9000.php?Text="+MSG)+"\"\>" ...

Utilizing Object Arrays in Chart.js for Optimal Performance

I'm struggling with using chart.js to create charts for my admin panel. I'm having trouble figuring out how to properly utilize my JSON array of objects in order to generate the correct dataset. What exactly should I be putting in the data field ...

Creating a string of DIV elements with PHP and mySQL - is it possible?

I am in the process of creating a well-formatted product list using data from an SQL database. The goal is to have my website display a store layout with small boxes containing brief information about each product that, when clicked, will open up detailed ...

Having issues with AngularJs functionality in a basic project

After creating a simple helloworld with angular, I am unable to see the result. The angular.min.js file is included in the html and loads correctly in the browser. Here is my code: <!DOCTYPE html> <html> <head lang="en"> <met ...

Troubleshooting Problem with ListItem Alignment in Material UI v0 involving Custom Avatar Component

Material UI version: v0.20.0 I'm facing an issue with aligning the leftAvatar value using the CustomAvatar component, as shown in the attached screenshot. Any assistance would be appreciated. CustomAvatar: The functionality of this component is cond ...

The functionality of the Vue model seems to be failing to work properly and is not carrying out its intended

In my form file, I have implemented the VUE input-field. I want this field to be displayed only when the option Manually set new password is checked. This particular issue is present in the last field. var app = new Vue({ el: '#app&ap ...