【问题标题】:Animate an added event but not a dropped one为添加的事件设置动画,但不为删除的事件设置动画
【发布时间】:2013-12-06 20:26:29
【问题描述】:

我正在使用FullCalendar 在我的应用程序上显示一些事件。当在日历上添加某些事件时,我想使用来自animate.css 的一些 css 动画。为此,我传递给 fullCalendar:

eventRender: function(ev,elm){
    $(elm).addClass("animated bounce");                
}

而且事件反弹得很漂亮。问题是每次拖动事件时都会为每个事件调用eventRender,因此当我拖动特定事件时,所有其他事件也会反弹:/ 事实上,我希望能够仅在我第一次加载事件时而不是在拖放时为事件设置动画。那么,既然eventRender 不知道他为什么要重新渲染所有事件,还有其他方法可以为它们设置动画吗?

这是一个显示问题的示例:http://jsfiddle.net/5H2CS/

【问题讨论】:

    标签: jquery fullcalendar animate.css


    【解决方案1】:

    我花了一点时间才弄清楚这一点,因为我很长时间没有使用fullcalendar,但这里有一些你可以使用的东西:http://jsfiddle.net/5H2CS/12/

    // track whether the element has been dropped inside the event fetcher:
    ...
      var eventObject = {
                title: $.trim($(this).text()), // use the element's text as the event title
                dropped: 0
            };
    ...
    
    // in the renderer callback: if event has not been dropped yet, animate it
    // and then, set the dropped status to 1
    eventRender: function(e, elm){
                if (e.dropped == 0) {
                   $(elm).addClass("animated bounce");
                   e.dropped = 1;
                }
            },
    ...
    

    像魅力一样工作:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-04
      • 1970-01-01
      • 1970-01-01
      • 2022-09-25
      • 1970-01-01
      相关资源
      最近更新 更多