Smoothly scroll through multi-column carousel using Bootstrap easing techniques

I'm looking to improve the scrolling functionality of this multi-item carousel. Currently, when clicked, it jumps to the next item instead of smoothly transitioning. I am seeking a way to make it transition or ease into the next section smoothly.

<style>
body {
    width: 1400px;    
}
.Blog {
    position: relative;
    background-color: #000;
}

.inner {
    overflow: hidden;
    font-size: 0;
    white-space: nowrap;
}

.Blog-item {
    border-left: 1px solid #fff;
    border-right: 1px solid #fff;
    display: inline-block;
}

.controlDiv {
    border-left: 1px solid #fff;
    border-right: 1px solid #fff;
    text-align: center;
}

.control {
    color: #fff;
    font-size: 20px;
    display: inline-block;
    padding: 4px;
}
</style>

<div class="Blog">
    <div class="inner">
        <div class="Blog-item" >
            <img src="http://placehold.it/727x356?text=1" alt="" />
        </div>
        <div class="Blog-item">
            <img src="http://placehold.it/727x356?text=2" alt="" />
        </div>
        <div class="Blog-item">
            <img src="http://placehold.it/727x356?text=3" alt="" />
        </div>
        <div class="Blog-item">
            <img src="http://placehold.it/727x356?text=4" alt="" />
        </div>
        <div class="Blog-item">
            <img src="http://placehold.it/727x356?text=5" alt="" />
        </div>
        <div class="Blog-item">
            <img src="http://placehold.it/727x356?text=6" alt="" />
        </div>
    </div>
    <div class="controlDiv">
        <a class="control control-left glyphicon glyphicon-menu-left" href=""></a>
        <a class="control control-right glyphicon glyphicon-menu-right" href=""></a>
    </div>
</div>
<script>
$(document).ready(function () {
    $('.control-right').click(function () {
        $(this).blur();
        $(this).parents('.Blog').find('.Blog-item').first().insertAfter($(this).parents('.Blog').find('.Blog-item').last());
        return false;
    });
    $('.control-left').click(function () {
        $(this).blur();
        $(this).parents('.Blog').find('.Blog-item').last().insertBefore($(this).parents('.Blog').find('.Blog-item').first());
        return false;
    });
});
</script>

Check out the fiddle for a live demo: http://jsfiddle.net/bcw8dysawk/z1wo4uy6/3/

Answer №1

If my understanding is correct, it seems like you are looking for something similar to the following:

http://jsfiddle.net/uh2skm0e/

To achieve this, I utilized jQuery's animate function to create animations on the webpage and integrated a modified version of your initial code into the callback function of the animate.

I implemented the 'next slide' functionality by adjusting the margin-left css attribute, and the 'previous slide' feature by altering the left css attribute.

You have the option to choose between both methods (typically left is more commonly used).

In addition, I found it necessary to include position:relative in the .Blog-item css style as the script manipulates z-index, which necessitates elements to have a defined CSS position.

A couple of things to note:

1) My solution relies solely on JavaScript. You could explore using the transition CSS property to create animations without JavaScript, but some adjustments to your code may be needed (this leads me to my next point)

2) Typically with sliders, the positions of elements are not actually altered in the markup...only the visibility settings (display CSS property) are changed. So when 'slide 2' is displayed, all other slides are set to display:none except for 'slide 2'. This means that simply adding a class to the visible slide with JavaScript will make it display...combining this with the transition CSS property can result in some nice effects.

Please let me know if this matches what you were looking for.

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

Having trouble accessing Google Spreadsheets in CSV format but unable to do so in JSON format?

I have been experimenting with Google's Visualization API to retrieve data from a specific row in a Google Spreadsheet based on a given string in the column labeled "key". When I run the following code, the success function is triggered and I receive ...

Tips for making a dropdown menu within an Ionic Side menu

Looking for guidance on creating a sub menu in the ionic framework? I'm new to AngularJS and ionic framework, but eager to learn. Below is the code snippet I used to create a dropdown list component: <ion-side-menu side="left"> <ion-co ...

In PHP, utilize MySQL to effectively segregate various types of searches

I'm currently working on a search form that allows users to choose between three different types of search options: by name, specialization, or location. However, the issue I'm facing is that the system only supports searching by name. How can I ...

Experiencing erratic outcomes with window.innerWidth in Mobile Safari

I am currently using JavaScript to determine the width of the browser: $(document).ready(function(){ var width = window.innerWidth; }); However, it seems that this method is producing inconsistent results. To showcase the issue, I have created a fun ...

What is the best way to specify svg attributes in virtual-dom?

Can attributes be added to SVG nodes using virtual-hyperscript in a virtual dom? Like this: var h = require('virtual-dom/h') h('svg', [ h('circle', {cx: 100, cy: 100}, 'some text') ]) I attempted this but the ...

Storing JSON data from a Github Gist in an array using the AJAX method - a step-by-step guide

I'm experimenting with storing JSON data in a variable and then randomly accessing it. (Superhero Alias Generator) The JSON data can be found on GitHub gist below I decided to try using the ajax method for the first time, but it doesn't seem to ...

Capture of Chrome pages is not possible when the extension has not been activated on the current page due to the absence of the activeTab permission

Hey there! I've encountered a tricky situation while trying to implement a Google extension. Due to technical limitations, I need to open the extension in a separate window as opposed to a disappearing pop-up, which is causing some issues with the fu ...

Tips for encoding AngularJS ng-model in real-time

Recently, I embarked on a new project and wanted to incorporate some AngularJS magic. The only obstacle is my limited expertise in AngularJS or JavaScript, making it difficult for me to figure out how to make it work. One key requirement is that the functi ...

The functionality of cloning an object is experiencing issues on a webpage containing jQuery code generated by a PHP script

<li style="padding: 5px; width: 150px; overflow: hidden; float: left; height: 202px;"> <div class="title"> <a href="/index.php?option=com_virtuemart&amp;view=productdetails&amp;virtuemart_product_id=68&amp;virtuemart_category ...

Transitioning from GeometryUtils.merge() to geometry.merge()

When upgrading from r66 to r67, a message pops up stating: DEPRECATED: GeometryUtils's .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead. The transition doesn't seem straightforward beca ...

retrieve the documents that correspond to a specific string in mongoose

Currently, I am working on integrating a search feature into a MERN stack application. The idea is to utilize the searchWord extracted from req.params.searchWord and fetch results containing that specific searchWord. Although my existing code serves its p ...

The Vue.js updated hook causing unnecessary page rerenders even when there are no changes in the state

Seeking to retrieve data from an api and utilize updated() to trigger a rerender upon a change in the state that stores the fetch url. However, encountering an issue where the updated hook continues to render even when there is no alteration in the state. ...

NuxtJS - Google Auth: ExpiredAuthSessionError: The authentication session has expired because both the token and refresh token have expired. Please try your request

I've been using nuxtjs for some time now. Everything related to authentication was working smoothly until my last update. However, after updating the nuxt.config.js file and moving the axios plugin from the plugins array to the auth config object, an ...

Guide to displaying options in the Vue material select box even when the default value is blank

I have implemented the material design framework vuematerial with vue.js. In traditional HTML, a selection box looks like this: <select> <option value="">You should initially see this</option> <option value="1">One</o ...

Using angularjs to include content from other files is known as

As I delve into the concept of creating directives in AngularJS, I am faced with the imminent end of Angular 1.x and the rise of Angular 2.x. The shift seems daunting, but I am determined to bridge this gap seamlessly. In my quest for clarity, I stumbled ...

A guide on adjusting the location of star ratings in Woocommerce

Is there a way to move the star ratings below the price on my archive and category pages instead of between the "buy it now" button and the price? I've attempted unhooking and floating left, but it doesn't seem to be effective. Below is my code s ...

When I refresh the page, I'm not sure how to properly save the localStorage

Let me explain the issue I am facing: I am developing a question game using React and JS where each round consists of answering a question. Upon successfully completing a round, the page refreshes and directs the player to a more challenging question based ...

Creating dynamic cubes in Magento with interact.js within a .phtml template

I utilized the interact.js library to create this code snippet, which functions perfectly on Chrome, Firefox, and w3schools "Try it Yourself" platform (unfortunately not compatible with Edge and IE for unknown reasons). However, when I include this code wi ...

css - Tips for reducing the speed of inertia/momentum scrolling on mobile devices

I have been working on creating a scrollable card gallery using a CSS grid layout. The structure I am following is similar to this: <div class="gallery-wrapper"> <div class="gallery-container"> <div id="card-1" class="gallery-ca ...

Using jQuery to load a POST response into an iframe

I am facing a complex challenge that is really testing my patience. I am tasked with creating a servlet for cobrowsing, with specific logic in place: a "master" user enters a URL in the address bar, and a POST method (form submission) sends this informatio ...