faylang/fay-jquery

How should we implement animations?

bergmark opened this issue · 1 comments

In my prototype I have:

hide       :: Double -> (Element -> Fay ()) -> JQuery -> Fay ()
hide = ffi "%3.hide(%1,function() { %2(this); })"

hideSlow   :: (Element -> Fay ()) -> JQuery -> Fay ()
hideSlow = ffi "%2.hide('slow', function () { %1(this); })"

hideFast   :: (Element -> Fay ()) -> JQuery -> Fay ()
hideFast = ffi "%2.hide('fast', function () { %1(this); })"

I've added the callback argument because it's the proper way to sequence animations, unfortunately the syntax gets a little messy when you use them like this.

  • Should we keep it this way?
  • Should we provide other functions without the callback for when you just want to chain normally?
  • I'm also considering changing the signature of hide so we just have hide :: Speed -> ... and not several functions
  • And i'm considering changing the callback signature to (JQuery -> Fay ()) since that's probably how you'd want to use it.

OK i did some things! See examples in test.hs on what it looks like now, in short, hide Fast jq without callback, and chainAnim to create sequences of animations.