Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7538337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:05:49+00:00 2026-05-30T07:05:49+00:00

Given a div square and given I already have a touchmove function on that

  • 0

Given a div "square"
and given I already have a touchmove function on that div and I can detect the position X in real time:

how can I implement the rubber band effect?

I mean: tap and drag to the left until the resistance reach the limit and if ou release the finger the square div goes back to its initial position with an easing animation

there is a simple math for that? or a plugin?

UPDATE

w/o jquery would be better if possible

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:05:50+00:00Added an answer on May 30, 2026 at 7:05 am

    Store its original position somewhere.

    Then on the dragend event:

    $(this).animate({
        top: original_top,
        left: original_left
    }, 'slow');
    

    Demo: http://jsfiddle.net/maniator/T8zYt/

    Full code (with jQuery draggable):

    (function($) {
        $.fn.rubber = function(resist) {
    
            var self = this,
                position = $(this).position(),
                selfPos = {
                    top: position.top,
                    left: position.left,
                    maxTop: resist + position.top,
                    maxLeft: resist + position.left,
                    minTop: resist - position.top,
                    minLeft: resist - position.left
                };
            self.draggable({
                drag: function() {
                    var position = $(this).position(), width = $(this).width(),  height = $(this).height();
                    if (position.left > selfPos.maxLeft || (position.left - width)  < selfPos.minLeft || position.top > selfPos.maxTop || (position.top - height) < selfPos.minTop) {
                        return false;
                    }
                },
                stop: function() {
                    $(this).animate({
                        top: selfPos.top,
                        left: selfPos.left
                    }, 'slow');
                }
            })
    
        };
    })(jQuery)
    
    $('selector').rubber(10);​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script that notifies the console log whenever a given div is
I currently have a div on my page that I have given a background
How can I test if a mouse is within a given div? I know
Given a DIV with a fixed width, is there a way to have it
Assume I have the following CSS: div { -my-foo: 42; } Can I later
I have web-pages based on widget and I have given all the div the
So I have this Div that has a roll over effect on it where
Given that we don't know the div's width beforehand? My idea: Calculate the div
I have a piece of jQuery that loops through each element in a given
In my html i have got div with given class. After clicking a button

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.