jQuery UI smooths out the transitions, making the effect more gradual and fluid

Is there a way to make my toggle sidebar scroll smoothly using jQuery UI? Currently, it has a jerky behavior and I would like it to have a smoother left/right effect.

I want the outer shell to slide smoothly just like the inner container does, instead of snapping once the inner div finishes easing.


$(".snapper").click(function() {
 $(".sidebar-wrapper").toggle("slide", { direction: "right" }, 1000);
 $("#sidebar").css("width" , "auto");
});

Check out the online example here:

Answer №1

There is an issue with the auto parameter. Adjust it to a specific value and your problem will be resolved.

$("#sidebar").css("width", "200px");

View the Demo here

CSS Styles

.o {
   display: block;
  float: right;
  width: 30px;
  border-radius: 10px;
  height: 300px;
  overflow: hidden;
  background-color: black; 
}

.out {
    display: block;
  float: right;
  width: 40%;
  border-radius: 10px;
  height: 300px;
  background-color: black; 
}

.i {
  display: none;
  width: 200px;
  border-radius: 10px;
  height: 200px;
  overflow: hidden;
  background-color: grey;
  margin: 10px 50px 10px 10px;
}

.i2 {
    display: block;
  width: 100px;
  border-radius: 10px;
  height: 100px;
  background-color: orange;
  margin: 10px 50px 10px 10px;
}

JS Script

$(document).ready(function(){
  $('.o').click(function(){
    $(this).toggleClass('out', 1000);

    if ($('.i').css('display') == 'block'){
      $('.i').fadeOut('slow');
    }
    else{
      $('.i').fadeIn(1000);
    }
  });
});

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

What is the best way to transfer the value of a <span> element to a different <div> using jQuery or JavaScript

Is there a way to move or copy the price and insert it into the <div class="info"> using jQuery? The code I'm currently using is returning an unexpected result of "102030". jQuery(document).ready(function($) { $(document).ready ...

Creating a Dynamic List in JQuery Fancy Box for an iframe

I am new to using JQuery and I have a table with a checkbox. When the checkbox is clicked, I want a dynamic list to appear in a pop-up window. I've been having trouble implementing this. <html> <head> <label align="center">Select a ...

Modify a single row within a column with Jquery

I have been working on a project that involves using jQuery with JSON data to populate an HTML table. However, I am facing an issue where when I try to do some inserts, I need to update multiple rows in one column, but it is not functioning as expected - i ...

Increasing the values of jQuery variables

I've written this code to assign different ids to variables, as demonstrated below: var numgrid = jQuery('.panel-grid').length; for (var i = 0; i < numgrid; i++) { var currentId = "#pg-"+id+"-"+i; if (jQuery(currentId)[0]) ...

`Generating dynamic content based on ajax response``

Hey there! I've got a little challenge on my hands. I've set up 3 input boxes that act as table cells (the header). When the input in one of these boxes changes, a script runs. This script triggers a function that pulls data from my database thro ...

Centering a Font Awesome icon within its parent element

Below is the code I am using: <div style="width:60px; height:60px; background-color: lightgrey;"> <a class="" href="javascript:void(0)" style="color: black; width: inherit; height: inherit;"> <i class="fa fa-lg fa-play" aria-hidden="t ...

ASP.NET MVC does not automatically refresh when changes are made to the CSS file

Currently, I am diving into the world of Bootstrap 4 within an ASP.NET MVC project, exclusively making changes to the index.cshtml file in JetBrains Rider. However, I've encountered a strange issue that has me stumped. Each day, when I begin writing ...

"Utilizing JSON data to implement custom time formatting on the y-axis with AmCharts

Looking to convert minutes to hh:mm:ss format in my JavaScript code var allDataTime = [{ date: new Date(2012, 0, 1), "col": "LONG CALL WAITING", "duration1": '720', "duration2": '57', "duration3": ...

Using Javascript to dynamically retrieve accordion content from a dynamically generated ID

I am currently working on developing a more intricate accordion feature. The accordion will consist of 4 buttons (section 0-3) with unique content (lorem ipsum 0-3). Clicking on "section 0" should reveal "lorem ipsum 0", while clicking on "section 1" shoul ...

Troubleshooting: Why isn't the Access-Control-Allow-Origin header functioning correctly?

I'm currently trying to address the HTTP OPTIONS method by including an Access-Control-Allow-Origin header that mirrors the information in the Origin header from the request. Unfortunately, it seems like this approach isn't functioning properly, ...

Divider displayed between images in Internet Explorer 8

On my website, I have arranged four images in a square using the code below: <div id="tempo_main"> <div id="tempo_content"> <div style="text-align: center;z-index: 3;position: absolute;right:350px; left:350px; t ...

In a remarkable design with an array of buttons and an individual div assigned to each, a fascinating functionality unfolds. Whenever a

https://i.stack.imgur.com/emhsT.png When I click on the first "Respond" button, I want the adjacent text box to disappear. Currently, if I click on the first "Respond" button, both text boxes will disappear instead of just the first one. $('.comment ...

Trigger the postback URL using a different button

I am trying to achieve a functionality where I have two buttons: ButtonA (normal) and ButtonB (with a postbackurl). What I want is for ButtonB to be executed when ButtonA is clicked. <asp:button ID="ButtonA" runat="server" text="Button" /> <asp: ...

Accessing PHP variables in JavaScript

Hi there, I am new to all this. I am trying to figure out how to use a PHP variable in JavaScript. Here is a snippet of my code (popup.php): <?php $id_user = $this->session->userdata('id'); ?> <script type="text/javascript"> ...

Preserve jQuery-enhanced webpage changes permanently

I am looking to permanently save modifications made on an HTML page using JQuery. I have come across suggestions about achieving this by sending an Ajax call and storing the data in a database table. However, I am unsure about what exactly needs to be save ...

Cease the AJAX Requests

In order to successfully load my page, I have implemented a series of AJAX POST requests in a specific sequence using the .done() function: $(document).ready(function(){ // Load Recipients & documents $("#page").hide(); $("#loading").show( ...

React component fails to display content following execution of Jquery Ajax request

Utilizing a basic jQuery ajax function to retrieve inline HTML code from an API $.ajax({ url: url, headers: { 'Accept': 'application/javascript' }, dataType: 'html', beforeSend: function(){ $('.load-mor ...

What's causing ng-show to malfunction in IE11 on AngularJS?

I am experiencing a strange issue with my code - ng-show works perfectly fine on Firefox, but not on IE 11. <div ng-show="isExist" class="panel panel-default"> Here is the relevant code snippet from the controller: $scope.isExist = false; if(user ...

Prevent Image Distortion in HTML and CSS

Is there a way to prevent a background image from stretching in html/css? Take a look at the current code below, where the image behind a button appears like this: #backImage6{ /*@editable*/background-image:url(https://images.unsplash.com/phot ...

Expand a section of the background picture

I am working with an image that contains multiple flag images: https://i.stack.imgur.com/xg0iM.jpg I have a div element with the dimensions: width:100px; height:50px. My goal is to resize each flag to fit inside it: .flag{ wi ...