-4

In angular 2 can I do something like

<div (onEnter)="doSomething()">
</div>

which would trigger when the windows is near an element within a large component.

I am trying to avoid having to write a bunch of components with custom entrance animation. so I wanted to set the style to reference animate.css in the dosomething() function.

Philip Brack
  • 1,340
  • 14
  • 26

1 Answers1

0

Yes, only the syntax dictates (enter) rather than (onEnter).

Plus, you're using angular2, hence the proper usage is of LESS or SCSS files. For pre-processing style files read here http://lesscss.org/

  • 1
    I used
    within my component and the test() function is never called as I scroll through the page.
    – Philip Brack Dec 28 '16 at 18:51
  • I see what you mean now, but (enter) and (onEnter) refer to mouse enter, not windows scrolling. There's a (scroll)/(onscroll event) but I think you might find this solution more suitable :[link]http://jsfiddle.net/ADukg/4831/ Use the 'raw' object to determone offsetHeight and thus location of object on window. The fiddle was a solution to an issue presented here [link]http://stackoverflow.com/questions/21989923/scroll-event-is-not-fired-inside-directive-angular-js Plus, if you can post more or even all of your code it would be more beneficial. – Mr. Anderson Jan 01 '17 at 08:36