Permalink
Browse files

Note to self

  • Loading branch information...
1 parent daefc05 commit 3c9a91b6dfb8fa19df4287e783171ff56b8b2bda Jason Johnston committed Jun 3, 2010
Showing with 7 additions and 0 deletions.
  1. +7 −0 sources/event_handlers.js
@@ -10,6 +10,13 @@ var lastW, lastH, lastX, lastY,
*/
function update() {
init();
@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?

@lojjic

lojjic Jul 13, 2010

Owner

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

@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.

@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,

0 comments on commit 3c9a91b

Please sign in to comment.