Modifying DOM (slideDown/slideUp) with AngularJS and jQuery

后端 未结 2 1371
说谎
说谎 2021-02-02 12:29

I\'m trying to implement a slideDown/slideUp animation with AngularJS. I can\'t use CSS3\'s transition (unfortunately) since the height is set to auto

2条回答
  •  离开以前
    2021-02-02 12:32

    Alternatively, you can use AngularJS's $animate:

    .animation('.slide', function() {
        var NG_HIDE_CLASS = 'ng-hide';
        return {
            beforeAddClass: function(element, className, done) {
                if(className === NG_HIDE_CLASS) {
                    element.slideUp(done); 
                }
            },
            removeClass: function(element, className, done) {
                if(className === NG_HIDE_CLASS) {
                    element.hide().slideDown(done);
                }
            }
        }
    });
    

    Use ng-hide or ng-show to show or hide the description.

        
  • {{entry.title}} more?

    {{entry.description}}

  • See JSFiddle

    P.S. you must include jquery and angular-animate.js

提交回复
热议问题