【问题标题】:How to animate enter and leave of MeteorJS {{#if}} block?如何动画进入和离开 MeteorJS {{#if}} 块?
【发布时间】:2015-06-03 13:56:36
【问题描述】:

标题确实说明了一切。给定一个模板:

{{#if selection}}
    <div class="something">
        <p>To Animate</p>
    </div>
{{/if}}

如何控制.something的进入和退出动画?

谢谢。

【问题讨论】:

    标签: animation meteor spacebars


    【解决方案1】:

    您必须从 DOM 中创建一个包含动画内容的模板:

    <templte name="somthing">
    <div class="parentdiv">
    {{#if selection}}
        <div class="something">
            <p>To Animate</p>
        </div>
    {{/if}}
    <div>
    </template>
    

    然后你可以使用 _ui_hooks

    Template.something.onRendered(function() {
    
    this.find('#task-list')._uihooks = {
          insertElement: function(node, next) {
            $(node).addClass('animate')
              .insertBefore(next);
    
            setTimeout( function () {
              $(node).removeClass('animte');
            }, 20);
          },
          removeElement: function (node) {
            $(node).addClass('animate')
              .on(EVENTS, function() {
                $(node).remove()
              });
          },
        }
    });
    

    所以这里包含动画的 css 类是 animate

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-16
      • 1970-01-01
      相关资源
      最近更新 更多