【问题标题】:Bootstrap Modal zoom out animationBootstrap 模态缩小动画
【发布时间】:2015-06-04 05:03:52
【问题描述】:

我正在尝试在 bootstrap-modal 的 github 存储库上的 hide()、based on the answer 上实现缩小动画(使用 Bootstrap 2.3.2)。

想法是添加一个 CSS 过渡,并拦截 hide 事件,类似于:

$modal.on('hide', function () {    
    $modal.css({top: 0, left: 0, transform: 'scale(0.1, 0.1)'});
//  return false;    // uncomment this line to see zoom out
});

问题是模态框在有机会看到动画之前就被隐藏了。返回false 会显示动画,但会阻止模态框完成隐藏。

如何完成隐藏过程但仍能看到动画?

请参阅http://jsfiddle.net/dtyohc28/5/ 的小提琴

TIA

【问题讨论】:

    标签: javascript jquery css twitter-bootstrap bootstrap-modal


    【解决方案1】:

    有点 hacky 但有效。 http://jsfiddle.net/dtyohc28/7/

    $modal.on('hide', function () {    
        $modal.css({top: 0, left: 0, transform: 'scale(0.1, 0.1)'});
        if($modal.css('top')!="0px"){
            setTimeout(function(){
                $modal.modal('hide');
            }, 750);
            return false;
        }
    });
    

    【讨论】:

    • 它有效,所以我赞成它,但如果可能的话,我更喜欢更清洁的解决方案。
    【解决方案2】:

    http://jsfiddle.net/dtyohc28/6/试试这个,而不是使用on('hide'),创建你自己的函数来控制它。

    $('#dismissModal').click(function(){
        $modal.css({top: 0, left: 0, transform: 'scale(0.1, 0.1)', opacity:'0'});
        setTimeout(function(){
            $('.modal').modal('hide')
        },750);
    });
    

    【讨论】:

    • 我考虑过,但它仅在使用按钮时有效,而不是在单击背景以关闭模式时。不过我赞成你的回答。
    猜你喜欢
    • 1970-01-01
    • 2020-01-07
    • 2013-02-27
    • 2014-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-16
    相关资源
    最近更新 更多