aullman/opentok-layout-js

use purpose-built animation library

Closed this issue · 5 comments

just trying to keep track of our discussion.

instead of optionally depending on jQuery, which has no good way to be declared via the bower.json, we could actually create a hard dependency on something that is smaller, less likely to collide, and specifically built to do animations.

one such library is the zepto.fx module, and it has the same API as jQuery. the only problem is that its not distributed on bower, and even the "clones" do not expose the fx module (with any of its dependencies) on its own.

i think that for now, we just stick to what we've done, which is do a runtime detection of jQuery and use it to animate. one thing we can do to make it a bit nicer is do a console.warn() if the user specifically requested to animate but jQuery wasn't found.

Alternatively we just have a hard dependency on jQuery, remove all of the OT.$ calls and replace it with jQuery.

Adding a dependency on zepto.fx while making it lighter weight if you're only using opentok-layout-js will actually add an extra dependency if you already have jQuery. Which is the case everywhere we currently use opentok-layout-js.

it looks like we've gone the route of a hard dependency on jQuery. 😢

why don't we go back to conditionally checking that it exists, but not actually calling noConflict()? it seems like the only reason to use noConflict() would be if we inlined the jQuery source and wanted to make sure we got our version and everyone else got the version the downstream author intended. otherwise there's no point in using that API.

i still think we ought to go the route of using more purpose-built, smaller libraries. even if it means there's some dead code in the end build. i think the more we push that out into the world, the more we are doing to help developers understand newer and more modern best practices.

@aoberoi no, things still work without jQuery. In fact I now run the tests both with and without jQuery to make sure that isn't broken see #21

I'm not calling noConflict() anymore because it was breaking apps that were using jQuery. It was taking away the window.$. Is that what it's supposed to do?

I think maybe the best thing to do is let people pass in their own animation library, instead of using the jQuery one. So let them pass in an animate function that does the animation.

Now using CSS transitions is the preferred way to go and works well