1

The following example is probably the easiest way to try and explain the effect I'm trying to achieve:

http://jsfiddle.net/qSscJ/2/

Code:

$(function() {
    $('#handle').click(function() {
        $('#box').toggle('slide', { direction: 'right' });
    });
});

Click on the blue handle to make the entire red box collapse. How do I keep the blue handle visible after the box is collapsed (while keeping the handle anchored to the edge of the box)? I'm open to other jQuery UI APIs to achieve this effect.

2
  • put the handle out side of box Commented Apr 2, 2013 at 4:37
  • How do you keep it anchored to that left edge of the box though? Commented Apr 2, 2013 at 4:38

1 Answer 1

2

You could do just animate the width directly so the element doesn't get marked as hidden at the end of the animation:

$(function() {
    $('#handle').click(function() {
        $('#box').animate({width: "0px"}, 1000);
    });
});

But, it would be much better to change the design so that the blue tab was not contained within the box you're closing like here: http://jsfiddle.net/jfriend00/gKQrv/.

$(function() {
    $('#handle').click(function() {
        var box = $('#box');
        var targetWidth = box.width() > 0 ? 0 : 150;
        box.animate({width: targetWidth + "px"}, 1000);
    });
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.