This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Nick Bewley
Posted Aug 11 - Read on Facebook

How to trigger an event on MouseOver on the body (ie. the whole preview area)?

Tried:

• document.on Events.MouseOver, ->
• document.body.on Events.MouseOver, ->
• document.body.content.on Events.MouseOver, ->
• body.on Events.MouseOver, ->
• etc., etc.

Can anyone point me towards that magic combination that will get me there? Thanks a ton!

4 Comments

Joshua Tucker

Hey Nick! Document (http://www.w3schools.com/jsref/dom_obj_document.asp) (HTML DOM) doesn't extend EventEmitter (which allows you to do .on / .off on layers in Framer - it's build in that way to make event listeners easier). You need to use HTML add/removeEventListener with DOM-supported events (http://www.w3schools.com/js/js_htmldom_eventlistener.asp).

document.addEventListener "mouseover", ->
do whatever

OR using a function as the call handler

printHello = ->
print "Hello"

document.addEventListener "mouseover", printHello

Nick Bewley

Yasss. Makes sense thanks Joshua

Joshua Tucker

Nick Bewley Anytime!

Jordan Robert Dobson

Great explanation Joshua

Read the entire post on Facebook