0

I tried this but it's immediately invokes addClass after opening website :

function onMouseOver(element, event) {
  element.addEventListener("mouseover", () => {
    event
  })
}

onMouseOver(startAnim, addClass(panelLeft, 'hidden-l'));
onMouseOver(startAnim, addClass(panelRight, 'hidden-r'));
Rajesh
  • 24,354
  • 5
  • 48
  • 79
Marcin
  • 3
  • 2
  • Adding parenthesis after function will make it run immediately. You can try `addClass.bind(null, panelLeft, 'hidden-l')`. This will bind context and arguments and return a reference instead. – Rajesh Nov 15 '18 at 05:53

1 Answers1

0

"bind" is what you are looking for and below you can see reference of how to use it.

function innerFn(a, b) {
  console.log('Inner fn called with params ',a ,b)
}

function outerFn(c, fn) {
  console.log('Outer fn called with params ',c)
  
  fn()
}

outerFn('1', innerFn.bind(null, '2', '3'))
Nitish Narang
  • 4,124
  • 2
  • 15
  • 22
  • Most of the topics are answered. We should look for similar post as we know the real issue and can formulate better search query. Once we have such post, we should share its link in comments section until you have privilege to close yourself – Rajesh Nov 15 '18 at 05:58
  • Sure @Rajesh. Will take care of this. :) – Nitish Narang Nov 15 '18 at 05:59