How can we prevent the restoration of size effects in jQuery UI versions 1.9 and above?

After implementing jQuery UI 1.9 or newer, I noticed that the size effect returns to its original state. Below is a snippet of my code:

http://jsfiddle.net/mQCxY/

$(function () {
    $('.circle').click(function () {
        $(this).effect("size",
            { to: {width: 50,height: 50}, origin: ['bottom', 'right'] },
            1000, function () {
                $(this).css({'background': 'blue' });
        });
    });
});

With jQuery UI version 1.8.18 (under jQuery 1.7.2), the shape properly shrinks and maintains its size. However, in later versions, it reverts back.

I also observed that the "origin" parameter does not work in higher versions of jQuery UI. I used

origin: ['bottom', 'right']

Which had no impact on jQuery UI 1.9 or above.

Is there a way to prevent the restoration of the size and effectively use the 'origin' setting in jQuery UI 1.8 or newer?

Answer №1

I have created a new function that will fulfill your requirements. Check out the working example on JsFiddle.

In this updated version, I replaced the effect with animate and modified the CSS properties for top and left to achieve the desired functionality. By default, it aligns to the top-left corner.

For instance:

If origin is set to ['bottom'], it behaves the same as ['bottom','left'].

If origin is set to ['right'], it is equivalent to ['top','right'], and so on.

function size(object, to, origin, duration, callback){
    var leftResult = '+=0';
    var topResult = '+=0';
    if (origin != null && origin.length != 0){
        if ($.inArray('right', origin) >= 0){
            leftResult= '+='+to.width;
        }
        if ($.inArray('bottom', origin) >= 0){
            topResult= '+='+to.height;
        }
    }
    $(object).animate({
        height: to.height,
        width: to.width,
        left: leftResult,
        top: topResult
  }, duration, function() {
    if (typeof callback == "function") callback($(object));
  });
}

You can simply enhance argument validation or customize the callback according to your needs.

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

Setting a fixed row height for Material-UI tables in ReactJS, even when the content is long

I'm currently working on a listing component using the material UI table in ReactJS. Within this table, I have a ResumeUrl field that can span over 3 or 4 lines, but I need to limit it to just 2 lines with the rest of the content being represented by ...

how to change the class of a div when clicking on a <p> element

Check out this code snippet: <p class="faq" onclick="toggleVisibility('answer1');"> How can I restrict email sending on my website? </p> <div id="answer1" class="hide"><sometext></div> these are my CSS styles! ...

As the user scrolls down, the navigation becomes obscured by the content

Whenever I scroll down on my website at Bradly Spicer, the navigation menu extends and ends up falling behind the content. This is the script I am using: .menu { position: relative; z-index:9999; } .post { background: #fff; border: 1px solid #ddd; font- ...

The functionality of the "#Next" and "#Prev" features in the Tiny carousel are currently not functioning properly within the MVC project

Looking to implement a simple content carousel using jQuery 2.1.3 in my project. Previously used a non-responsive jQuery content carousel and switched to find a responsive option:Tiny Carousel Added Tiny Carousel's .js and .css files to Bundles.confi ...

I am looking to implement a required alert for a radio button that mimics HTML5. How can

When using the input type text, adding the required attribute prevents the form from submitting and prompts the browser to focus on the required field with an alert instructing to fill it out. On the other hand, when applying the required attribute to t ...

Is it possible to manipulate content using jQuery?

I need help figuring out how to update the content within a span tag when a user clicks on a button. The specific span tag I am trying to target has a class called fa_button_id_counter and an id that corresponds to the post id. Despite my efforts, I haven& ...

What could be causing the font of the background text to change when CSS3 animation is applied?

Have you ever noticed a font style change in the background text when applying CSS3 animations for opacity and scale transforms? I have some text content on my page, including a "Click me" link that triggers a popup with a CSS3 animation. However, I'v ...

Converting CSS properties to MaterialUI Styles in ReactJS: A step-by-step guide

In my CSS, I've included the following code: [contentEditable=true]:empty:not(:focus):before{ content:attr(data-text) } This snippet allows me to display a placeholder inside a content-editable div when it is empty. Since I am using Material-UI ...

Dynamic sliding effect in CSS for seamless showing and hiding of div elements

I stumbled upon a fantastic solution in these forums How to create sliding DIV on click? However, what I really wanted was for the content to fade in and out with just a click of a button. Here is the code snippet I am currently working with: <html> ...

Guide to retrieving all selected options from a multi-select box using jQuery

I have a lengthy form that is constantly changing and includes multiple Select Options such as <select class="common_dt_select" id="select_15" data-col-index="15"> <option value="">All CC Status</option> <option value="0">De ...

I encountered a SyntaxError indicating a missing ")" right before utilizing jQuery in my code

When trying to run the code below, I encountered an error in the console stating SyntaxError: missing ) after argument list. $(document).ready(function() { $(".blog-sidebar-form form").before("<p class="blog-sidebar-inform>Dummy Text</ ...

What is the process for receiving the response from an AJAX request that is using the application/x-octet-stream format?

Currently, I am utilizing JSONP to retrieve content from an API. The problem lies in the fact that the link I am using returns a file meant to be saved as CSV with the response being application/x-octet-stream. Upon checking Chrome developer tools, I enc ...

Create a custom overlay for an image that is centered horizontally and does not have a fixed width

I'm working with this HTML setup: <div class="container"> <img class="image" /> <div class="overlay"> <div class="insides">more content here</div> </div> &l ...

The scatterplot dots in d3 do not appear to be displaying

My experience with d3 is limited, and I mostly work with Javascript and jQuery sporadically. I am attempting to build a basic scatterplot with a slider in d3 using jQuery. The goal of the slider is to choose the dataset for plotting. I have a JSON object ...

Guide to updating current rjs files to incorporate jQuery and json in Rails 3

Currently, in my Rails 3 application, I am using rjs to render partials in my controllers. An example of this is when saving a new item to a table, the table gets refreshed: respond_to do |format| format.js { render :update do |page| ...

Tips for preserving the jquery inputmask after updating the DOM

It's difficult to explain, but here is a snippet showcasing the issue. (function() { var PhoneNumber = function() { this.name = ko.observable(); this.phone = ko.observable(); }; $('[data-mask="phone"]').inputmask({ mask ...

Guide to sending back a promise using JQuery

Here is the Durendal code I am working with: var variable = ko.observable(""); function activate(){ return myModel.doSomething(variable); } The doSomething function looks like this: function doSomething(variable){ if(someCondition) return ...

What is the best way to add animation to the border-style using jQuery?

I've successfully animated the border-color and border-width using borderColor and borderWidth, but I'm now curious about animating the border style with borderStyle. Unfortunately, my searches so far have been unsuccessful. Is there a way to ani ...

Preventing absolute div from spilling out of its parent container

Within a parent container, I have a lengthy div. I believe that it needs to be positioned absolutely in order to allow horizontal scrolling. My goal is to only display the portion inside the parent div. I attempted setting overflow: hidden on the parent ...

Adjusting the Aspect Ratio of an Embedded YouTube Video

<!DOCTYPE HTML> <head> <style> body { overflow: hidden; margin:0; } </style> </head> <body> <iframe id="video" src="https://www.youtube.com/embed/U4c9bBeUe4M?modestbranding=1&sh ...