javascript - AngularJS - 无法在 'animate' : Partial keyframes are not supported 上执行 'Element'

标签 javascript jquery angularjs

我正在获取

Error: Failed to execute 'animate' on 'Element': Partial keyframes are not supported.

在 ng-click 方法中对 dom 元素进行动画处理时。我使用 $event 在 ng-click 中传递 DOM 引用。

这是 fiddle 链接 - fiddle containing issue

$event.currentTarget.animate({
    'height': '400px',
    'width': '400px'
  });

虽然我可以使用 jQuery 为 DOM 元素设置动画 - working fiddle

$($event.currentTarget).animate({
    'height': '400px',
    'width': '400px'
  }, 1000);

我无法弄清楚为什么它不能使用简单的 Angular 代码。

最佳答案

jQLite 不提供开箱即用的 animate 方法,如果你想要它,那么你必须加载 jQuery(在 Angular 之前) js,这样 angular.element 也将具有 jQuery 方法)。

另一种 Angular 解决方案是您可以加载ng-animate模块并让它在myApp模块内注册。您不需要在 element

上使用 ng-click 处理程序
//below animation would apply on `container` class
myApp.animation('.container', [function() {
  return {
    click: function(element, doneFn) {
      angular.element(element).animate({
         'height': '400px',
         'width': '400px'
      });
    }
  }
}]);

关于javascript - AngularJS - 无法在 'animate' : Partial keyframes are not supported 上执行 'Element',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39046467/

相关文章:

javascript - 是否有用于制作iPad Web应用程序的优秀HTML5和JavaScript初学者教程?

javascript - 带有ajax的django模板上的CSS元素

javascript - Angular 1.6 无法在页面中放置多个自定义组件

javascript - 在 Javascript 中创建和使用模块

javascript - 删除 DIV 中的 SPAN 和 BR

javascript - 在函数/promise 范围之外使用对象

jquery - laravel - 基于先前选择的动态下拉列表

javascript - 移动网站上的变色(平衡)背景图片

javascript - 如何让我的指令在 ng-bind-html 内容之后运行并对其进行操作?

javascript - 是否可以在 Angular 中使用获取请求?