2

I was wondering if there's a jQuery function that do the same effect as this code without using jQuery UI?

$(selector).show('slide', { direction: 'right' }, 300);
2
  • jsfiddle.net/Jwkw6/1 Commented Aug 22, 2013 at 14:29
  • @MelanciaUK, my question is about how to achieve the effect of the code i gave above WITHOUT using jQuery UI. Commented Aug 22, 2013 at 15:25

2 Answers 2

3

No, but you can animate the element as you wish.

Here's a great tutorial

Sign up to request clarification or add additional context in comments.

Comments

0

Here's a quick plugin that I came up with. It basically animates the width and opacity properties:

$.fn.slideRight = function(duration, callback) {

    duration = duration || 300;

    return this.each(function() {
        var $this = $(this),
            css = getInitialStyle($this);

        $this
            .css({width: 0, display: 'block'})
            .animate(css, duration, callback);
    });

    function getInitialStyle($el){
        var css = $el.data('initialStyle');

        if(!css || !css.width || !css.opacity) {
            var isHidden = $el.is(':hidden');
            if(isHidden) $el.show();
            css = {
                width: $el.width(),
                opacity: $el.css('opacity')
            }
            if(isHidden) $el.hide();

            $el.data('initialStyle', css);
        }

        return css;            
    }
}

And here's the live demo.

1 Comment

Yes, you should animate the margin-left property to something similar to '+=' + css.width

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.