Tips for resolving the final item issue in Owl Carousel when using right-to-left (RTL)

Encountering a bug with the rtl setting in owl-carousel. When the rtl is applied to the slider and I reach the last item, the entire slider disappears! Here's the code snippet:

var viewportWidth = $("body").innerWidth();
        if (viewportWidth > 1000) {
            $('.owl-carousel').owlCarousel({
                rtl: true,
                center: true,
                loop: false,
                items: 10
            })
        } else if (1000 >= viewportWidth && viewportWidth > 500) {
            $('.owl-carousel').owlCarousel({
                rtl: true,
                center: true,
                loop: false,
                items: 5
            })
        } else if (500 >= viewportWidth) {
            $('.owl-carousel').owlCarousel({
                rtl: true,
                center: true,
                loop: false,
                items: 3
            })
        }

If you run the above code and navigate to the last item in the slider, you will observe the issue.

Answer №1

If you simply delete 'center: true' from the code, it should work perfectly.

Another suggestion would be to use Owl Carousel's default responsive feature instead of specifying settings for each breakpoint individually like this:

responsive : {
    // styles for screens wider than 0px
    0 : {
        option1 : value,
        option2 : value,
        ...
    },
    // styles for screens wider than 480px
    480 : {
        option1 : value,
        option2 : value,
        ...
    },
    // styles for screens wider than 768px
    768 : {
        option1 : value,
        option2 : value,
        ...
    }
}

For more details, refer to the official documentation.

By the way, I couldn't help but notice... On line 9, shouldn't it look like this? -

else if (1000 <= viewportWidth && viewportWidth > 500)

Answer №2

Owl Carousel doesn't play well with caching plugins like WP3 Total Cache (and possibly others).

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

Designing a layout for a chat application that is structured from the bottom up

I'm currently in the process of designing a web application for a chat platform. I have access to an API that provides a list of messages: chatsite.com/api/thread/1/messages/ [ { "id": 2, "sender": { "id": 2, ...

What is the most effective method to arrange absolute divs generated randomly in a grid-like formation?

Hey there! I'm facing an intriguing challenge with my app. It's designed to generate a variable number of divs which are always in absolute positioning. Unfortunately, making them relative is not an option due to some other factors within the app ...

Nuxt Vuex global state update does not cause v-for loop components to re-render

I am struggling to effectively use Vuex global state with re-rendering child components in Vue.js. The global state is being mutated, but the data does not update in the v-for loop. Initially, all data is rendered correctly. However, when new data is intr ...

Guide on how to add multiple options to a select element in HTML using prototype.js

What is the best way to add multiple options to a select tag in HTML using prototype js? Appreciate your help. ...

What is the best way to test chained function calls using sinon?

Here is the code I am currently testing: obj.getTimeSent().getTime(); In this snippet, obj.getTimeSent() returns a Date object, followed by calling the getTime() method on that Date. My attempt to stub this functionality looked like this: const timeStu ...

Selenium allows the liberation of a webpage from suspension

I'm facing an issue with resolving the suspension of a website as shown in the image below. My goal is to access a ticket selling website every 0.1 seconds, but if it's busy, I want it to wait for 10 seconds before trying again. Visit http://bu ...

Datagrid in AngularJS does not update filters upon refresh

Currently, I am attempting to implement name filtering with Angular JS using the following library: https://github.com/angular-data-grid/angular-data-grid.github.io. However, an issue arises when searching as the results do not refresh immediately; only up ...

I have a brief snippet of JavaScript code that demonstrates how to access properties

Is there a way to make the following javascript code more concise? It creates an object with the element's id as key and the element itself as value. const createWrapper = elem => { return {[elem.id]: elem} } Example: createWrapper({id:&apos ...

Utilize Angular's $location to add or update the current URL parameter

I'm working on a function for handling multiple parameters in the URL when clicking an element. Specifically, I need to check if parameter pthree exists, update it to a new value without duplicating, and if it doesn't exist, append it to the curr ...

What is the best way to fill radio buttons within a form that is being displayed as a string in PHP?

Looking for assistance with a PHP script that receives data from jQuery through AJAX and then executes a query to retrieve information from MySQL. Once the data is retrieved, I aim to populate a series of radio buttons within a form with this data. The for ...

Restrict the usage of JQuery to display HTML code a restricted number of instances

On my webpage, I have the following HTML code and I am attempting to insert a small piece of HTML after each feed item. However, I only want this additional HTML to be displayed three times. The HTML: <div class="wp_rss_retriever"> <ul class=" ...

What's the Best Way to Add a Border to My Two-Column Form?

I'm currently working on a reservation form for my website with a 2-column layout. In one column, I have tables, and I've been trying to add a divider between the columns but haven't found a solution yet. Despite researching ways to add a d ...

There is no index signature that accepts a parameter of type 'string' in the type '{ [key: string]: AbstractControl; }'

I'm currently tackling a challenge in my Angular project where I am creating a custom validator for a reactive form. However, I've encountered an error within the custom validators function that I am constructing. Below you will find the relevan ...

What could be the reason for req.route displaying the previous route instead of

Question: const router = express.Router(); router .route('/:id') .delete( validate(messageValidator.deleteById), MessageController.deleteById, ) .get( validate(messageValidator.getById), MessageController.getById, ); ...

The onclick function is malfunctioning when attempting to use the Windows Phone app in Visual Studio 2015

web development <div class="align_center"> <div class="btn EmployeeloginBtn" **onclick="new Employee().connect()**>CONNECT</div> </div> Employee.js: var Employee = function() { var self = this; self.connect = fu ...

Exploring JavaScript: Accessing an array object within another object

I'm having trouble accessing an array object within an object in JavaScript. The object structure is as follows: categories: Array(5) 0: name: "Electronics" subCategories: Array(16) 0: name: "Video Games & Accessories" __typena ...

Not all Angular Material2 styles are being fully applied

One issue I am encountering is that styles for components such as <mat-chip> or <button mat-raised-button> (the only ones I have found) are not working properly and appear gray by default. However, styles do apply correctly to the <mat-card& ...

Having trouble determining the dimensions of a newly added element

I am using jQuery to dynamically add an image but I am unable to retrieve its dimensions (width and height). Below is the snippet of code from my HTML file: <input type="checkbox" id="RocketElement" data-id="1"> And here is the JavaScript/jQuery c ...

Issue with CSS rendering in Internet Explorer

Although my website appears perfectly in Firefox, the entire style sheet doesn't seem to load properly in IE 7. It's only displaying certain styles. Any assistance on this issue would be greatly appreciated! ...

What is the method for altering the value of a variable within a function?

Is there a way to update the value of a variable? I attempted the method below, but unfortunately, it was unsuccessful: function UpdateData() { var newValue = 0; $.ajax({ url: "/api/updates", type: &quo ...