[英]ESLint complaining about GreenSock inside Angular app
我正在使用GreenSock的Draggable插件开发一个小的Angular应用程序。 一切都按预期进行; 但是,我使用的是ESLint,并且抱怨没有定义TweenMax和Draggable。
74:7 error "Draggable" is not defined
133:7 error "TweenMax" is not defined
133:78 error "Bounce" is not defined
我具有在控制器中设置可拖动元素以及在控制器中设置一些补间的功能:
// Set up GreenSock Draggable dial
function setUpDraggableElement(element) {
Draggable.create(element, {
type: 'rotation',
onPress: onDialTouch,
onRelease: onDialRelease,
onDrag: onRotateDial,
liveSnap: function(endValue) {
return Math.round(endValue / 20) * 20;
}
});
}
...
TweenMax.to(angular.element('.selector'), 0.5, { scale: 1.1, ease: Bounce.easeOut});
我是Angular的新手。 我需要将它们包装在某种指令之类的东西中吗?
如果您的应用程序按预期运行,我相信这只是ESLint的问题。
GSAP在一个文件(或每个文件在其自己的文件)中定义“可拖动”,“ TweenMax”和“反弹”,而您在另一个文件中使用这些名称。 ESLint着眼于单独的文件,因此它警告说,名字尚未确定。
您需要做的是通知ESLint,“ Draggable”,“ TweenMax”和“ Bounce”是全局变量(在文件外部定义)。 像这样:
/*global Draggable, TweenMax, Bounce*/
这是完整列表,只需以相同的方式将其添加到ESList配置文件中(我以相同的方式假设,我目前正在使用JSHint)。
https://greensock.com/forums/topic/13416-using-tweenmaxgsap-with-gulp/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.