Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Commit

Permalink
Note to self
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Johnston committed Jun 3, 2010
1 parent daefc05 commit 3c9a91b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sources/event_handlers.js
Expand Up @@ -10,6 +10,13 @@ var lastW, lastH, lastX, lastY,
*/
function update() {
init();

This comment has been minimized.

Copy link
@paulirish

paulirish Jul 13, 2010

if update calls init() and then init calls update() ....

I'm a bit confused. Could you explain this apparent recursion?

This comment has been minimized.

Copy link
@lojjic

lojjic Jul 13, 2010

Owner

The init function only actually does anything once. After getting called the first time it will do nothing.

This comment has been minimized.

Copy link
@paulirish

paulirish Jul 13, 2010

Okay then if update is called before init... then it'll complete all of init ... run update because its called from within there.. and then comeback and do update again.

So basically doing the meat of update twice.

Perhaps it makes more sense to put the conditional check in update .. if (!renderers) init(); to avoid this...

Does that make sense?

Great work btw. This is fantastic.

This comment has been minimized.

Copy link
@lojjic

lojjic Jul 13, 2010

Owner

Yes you're absolutely right. I'll rework that to avoid the double-execution. Thanks for catching that!


/* TODO just using getBoundingClientRect may not always be accurate; it's possible that
an element will actually move relative to its positioning parent, but its position
relative to the viewport will stay the same. Need to come up with a better way to
track movement. The most accurate would be the same logic used in RootRenderer.updatePos()
but that is a more expensive operation since it does some DOM walking, and we want this
check to be as fast as possible. */
var rect = element.getBoundingClientRect(),
x = rect.left,
y = rect.top,
Expand Down

0 comments on commit 3c9a91b

Please sign in to comment.