簡體   English   中英

ESLint抱怨Angular應用中的GreenSock

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM