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'));
1
  • 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. Commented Nov 15, 2018 at 5:53

1 Answer 1

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'))

Sign up to request clarification or add additional context in comments.

2 Comments

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
Sure @Rajesh. Will take care of this. :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.