News for hackers. Stuff that matters.
Re:Fold the DOM like paper by dmotz on Saturday November 30, 2013 @01:57PM (#6824084)
Author of OriDomi here. Really excited to see this at the top of HN.

I recently pushed out version 1.0 with some new features that make OriDomi easier to use.

It now has an internal queueing system so you can chain up effect sequences instead of dealing with callback handlers. [1] What looks like a chain of synchronous calls will now be deferred and sequenced automatically, e.g.:

folded.curl(50).collapse().setSpeed(2000).stairs(-29).foldUp().unfold();

Secondly, OriDomi elements are now fully responsive, meaning they adapt to changing dimensions caused by media queries, window resizing, etc. You can see this behavior with the demos by resizing your browser, or on the current iteration of my personal site. [2]

Finally, there are two new methods that make it easy to do custom folding behavior and content manipulation, .map() [3] and .modifyContent() [4]. The former lets you pass your own function to define folding based on input angle and panel index.

It's still relatively lightweight with zero dependencies and 7.6KB gzipped and minified. More than anything, a testament to what you can do with the modern browser API.

Looking forward to seeing what else people do with it. Check out the annotated source [5] for a look at how it works.

[1] http://oridomi.com/#queueing

[2] http://oxism.com

[3] http://oridomi.com/#custom

[4] http://oridomi.com/#content-manipulation

[5] http://oridomi.com/docs/oridomi.html

Re:Fold the DOM like paper by benihana on Saturday November 30, 2013 @02:03PM (#6824117)
This is really awesome, congrats!
Re:Fold the DOM like paper by jashkenas on Saturday November 30, 2013 @11:48AM (#6823591)
Lovely work on the annotated source code ... it explains a lot of the tricks and techniques, and makes the otherwise perhaps abstruse math accessible: http://oridomi.com/docs/oridomi.html
Re:Fold the DOM like paper by dmotz on Saturday November 30, 2013 @01:08PM (#6823892)
I owe plenty of gratitude to you for both CoffeeScript and Docco. Both made building this a pleasure.

For those interested in going beyond what the docs cover, the annotated source page is a great place to understand the inner workings.

Re:Fold the DOM like paper by elwell on Saturday November 30, 2013 @06:29PM (#6825167)
Just curious, why did you check for the existence of "console" on this line:

  console?.warn 'OriDomi: First argument must be a DOM element'
Re:Fold the DOM like paper by danenania on Saturday November 30, 2013 @06:52PM (#6825273)
window.console is undefined in some versions of IE if the developer tools aren't active.
Re:Fold the DOM like paper by dmotz on Sunday December 01, 2013 @12:17AM (#6826231)
That's right.
Re:Fold the DOM like paper by vanderZwan on Saturday November 30, 2013 @06:47AM (#6822908)
Funny coincidence, I just started a casual discussion about origami and programming with some friends yesterday:

So, my friend Torsten (who is really into papercraft and origami) explained to me the purity hierarchy within the papercraft community.

At the bottom is having to cut the paper and use glue in your creations. One level above that is if the form requires only cutting or tearing. Getting more and more pure is the form known as kirigami, which involves cuts but is made from a single sheet of paper as the base. At the top is origami - no glue, no cuts, only folds (although I'm not sure if there is such a thing as higher order origami), and ideally only one sheet of paper.

The comparison with functional programming ("no glue and cuts" and "no state") is so obvious I'm surprised I've never seen it in the wild - maybe because programming has more in common with algebra, whereas origami is geometric?

Although mostly unrelated to this library, we can conclude that some of the effects in OriDomi should be in a section called KiruDomi. ;)

Actually, from a usability perspective, I see a problem with using those effects, like "twist" and "fracture": once scrambled, it is not obvious from the shape in which way to drag to unfold again, unlike with an effect like "stairs"

Re:Fold the DOM like paper by danieldk on Saturday November 30, 2013 @06:53AM (#6822914)
The comparison with functional programming ("no glue and cuts" and "no state") is so obvious I'm surprised I've never seen it in the wild

Actually, it does occur in the wild ;):

http://www.cs.ox.ac.uk/jeremy.gibbons/publications/origami.p...

Re:Fold the DOM like paper by Adrock on Saturday November 30, 2013 @06:58AM (#6822921)
There's also a rich field of algebraic analysis of origami:

http://www.google.com/search?q=algebraic%20origami

Re:Fold the DOM like paper by vanderZwan on Saturday November 30, 2013 @04:01PM (#6824599)
It's always nice to be informed you're wrong in a constructive way. Thank you too!
Re:Fold the DOM like paper by vanderZwan on Saturday November 30, 2013 @08:41AM (#6823129)
Emphasis I've never seen it. ;)

Thanks!

Re:Fold the DOM like paper by iterationx on Saturday November 30, 2013 @07:42AM (#6822982)
This movie is quite good and it might still be available on Netflix, http://www.youtube.com/watch?v=tE4lqYzS2m0
Re:Fold the DOM like paper by victoro on Saturday November 30, 2013 @02:01PM (#6824106)
Thanks for the recommendation, Netflix doesn't have it available to stream but Amazon Prime does. Awesome film so far.
Re:Fold the DOM like paper by ams6110 on Saturday November 30, 2013 @08:53PM (#6825670)
At the top is origami - no glue, no cuts, only folds ... and ideally only one sheet of paper.

How would multiple sheets of paper really differ from cuts?

Re:Fold the DOM like paper by Houshalter on Saturday November 30, 2013 @03:18PM (#6824457)
Except the papercraft thing is meant to be an extra challenge, whereas functional programming has some practical advantages. Limiting to the bare minimum of just folding, not allowing things that would make it easier like glue or cutting, doing it without practical purpose but just to make impressive creations? I think the direct programming equivalent would be esoteric programming languages like brainfuck.
Re:Fold the DOM like paper by vanderZwan on Saturday November 30, 2013 @03:59PM (#6824591)
Limiting to the bare minimum of just folding, not allowing things that would make it easier like glue or cutting, doing it without practical purpose but just to make impressive creations?

My first experience with functional programming was being quizzed to solve certain maths problems with Haskell, and not being allowed to save intermediate results in a variable like an integer was really frustrating due to existing habits. Yes, yes, accumulators and recursion - point is our instructor gave us zero hints about how to think differently, and just kept saying "no, Haskell has no variables."

It might say more about how poorly guided my first encounter with functional programming was, but still, I'd say that is a lot like what you just described.

Re:Fold the DOM like paper by laureny on Saturday November 30, 2013 @09:13AM (#6823197)
> The comparison with functional programming ("no glue and cuts" and "no state")

Er... what? What does "glue and cuts" mean in functional programming?

And functional programming has state, like most other programming paradigms (see the ST and State monads).

Re:Fold the DOM like paper by vanderZwan on Saturday November 30, 2013 @04:03PM (#6824608)
I think I meant to say side-effects.
Re:Fold the DOM like paper by laureny on Sunday December 01, 2013 @02:18PM (#6828723)
Same observation, functional programming languages (even pure ones) have side effects, they just encode these side effects in types.
Re:Fold the DOM like paper by erikstarck on Saturday November 30, 2013 @07:10AM (#6822941)
If you're in to origami, check out the Can you fold it-challenge from Tetra Pak: http://canyoufoldit.com/

You get €5,000 for passing the qualification phase. Are you up to the challenge?

Edit: clarification, 10 teams will be selected from the qualification phase for the design phase and awarded €5,000. That's at least how I understand it :) (I am not involved in the competition in any way.)

Re:Fold the DOM like paper by pmr_ on Saturday November 30, 2013 @07:44AM (#6822987)
You get 5,000 if you complete the design phase, not the qualification phase. For that you need to complete the qualification phase AND be selected to go there.
Re:Fold the DOM like paper by idiot900 on Saturday November 30, 2013 @11:11PM (#6826052)
Seems like a tiny amount of money for something that would be worth quite a lot to them...
Re:Fold the DOM like paper by raghunathj on Saturday November 30, 2013 @08:43AM (#6823134)
Re:Fold the DOM like paper by supermatt on Saturday November 30, 2013 @06:43AM (#6822898)
Edit: Pull request sent (just .coffee as requested).

Looks AMAZING in webkit browsers! Sadly in firefox I get "jaggies" on the diagonal edges due to the lack of antialiasing.

I noticed that adding a transparent outline (outline: 1px solid transparent;) to the class ".oridomi-mask" I smoothed these jaggies. Although they look better they still aren't quite as crisp as webkit.

Re:Fold the DOM like paper by paales on Saturday November 30, 2013 @09:37AM (#6823246)
I assume that is because when you add an outline, the whole thing becomes the texture and the texture filtering is better than no anti aliasing it is still worse than properly rendered polygons.
Re:Fold the DOM like paper by dimillian on Saturday November 30, 2013 @07:42AM (#6822981)
I was in the train, I tested it on Safari iOS 7, works great! I love it.
Re:Fold the DOM like paper by kaivi on Saturday November 30, 2013 @06:52AM (#6822913)
Ugh, did I break it?: http://cl.ly/image/033W3F0b3s1U It's twist(6). Also, here is accordion(30) on document.body: http://cl.ly/image/0u0V3Y19342e/o And that's hover in the middle logo section: http://cl.ly/image/3Y172j1T0P3N/o That is a nice set of good-looking effects, I hope the project will live on.
Re:Fold the DOM like paper by dmotz on Saturday November 30, 2013 @12:46PM (#6823811)
Author here. Twist and fracture are among the more unconventional, dramatic methods that I left in for those looking for cut-up effects over folding. As you found out, you can even target the body element and the OriDomi will stretch to the window dimensions. That middle portion in the last screenshot looks like a stuck hover state probably due to the fact that you have nested OriDomi instances on the page. Thanks for trying it out.
Re:Fold the DOM like paper by laveur on Saturday November 30, 2013 @08:00AM (#6823025)
Doesn't work in the latest version of Safari on my Mac. (10.9 Mavericks, latest updates)

Update: Correction, didn't work the first time I went to the link but the second time was fine.

Re:Fold the DOM like paper by sjtgraham on Saturday November 30, 2013 @09:46AM (#6823264)
That is weird. I'm on 10.9 too and exactly the same happened to me.
Re:Fold the DOM like paper by aram on Saturday November 30, 2013 @10:10AM (#6823310)
Strange - everything is working the same way as in Chrome for me.
Re:Fold the DOM like paper by com2kid on Saturday November 30, 2013 @06:22AM (#6822875)
The horrible aliasing on everything (at least in FF!) makes this a real no go. Everything just looks terrible, and the performance isn't all that good either.

(No IE11 supports at all, I'm hoping it at least runs well in Chrome / Webkit browsers?)

(I hate to be negative, but the aliasing really is quite extreme! Sorry!)

Re:Fold the DOM like paper by RyanZAG on Saturday November 30, 2013 @06:26AM (#6822879)
I saw the problem in FF too. I checked it out in Chrome though and it looks much better - the aliasing effect is much less noticeable and performance is better. I'd guess it isn't properly optimized for FF somehow.
Re:Fold the DOM like paper by ux-app on Saturday November 30, 2013 @06:46AM (#6822903)
jaggies in Firefox can be solved with:

  outline: 1px solid transparent;
added to elements with class .oridomi-mask

It's a hack but it does give nice anti-aliased edges.

Performance is perfectly smooth for me even with the AA hack above on Windows.

Re:Fold the DOM like paper by com2kid on Saturday November 30, 2013 @08:35AM (#6823107)
> Performance is perfectly smooth for me even with the AA hack above on Windows.

Playing with it more, my performance complaints appear to actually be caused by individual elements losing my mouse when I am clicked down on them and then drag outside of their bounds. This makes it seem like I have to keep re-grabbing things, the end effect is a lot of stuttering as I release and reclick on an element to grab a hold of it ahead.

Purely perceptual, but still nasty.

Re:Fold the DOM like paper by EvanL on Saturday November 30, 2013 @03:25PM (#6824483)
Haha, very cool, great job! Plenty of creative application opportunities!
Re:Fold the DOM like paper by woah on Saturday November 30, 2013 @01:14PM (#6823920)
Looks awesome, but it seems like all the examples on the page incorporate a weird "wiggling" effect in addition to the folding. Is it possible to turn this off?
Re:Fold the DOM like paper by dmotz on Saturday November 30, 2013 @01:19PM (#6823938)
Yes. That wiggling is the "ripple" mode I added recently which adds a cascading delay. It's disabled by default when creating new OriDomi instances, but I enabled it for the demos on this page. You can also programmatically turn it on and off:

http://oridomi.com/#ripple

Re:Fold the DOM like paper by yuvals on Sunday December 01, 2013 @07:55AM (#6827090)
Very nice!
Re:Fold the DOM like paper by taigeair on Saturday November 30, 2013 @02:16PM (#6824175)
Nice
Re:Fold the DOM like paper by raghunathj on Saturday November 30, 2013 @08:33AM (#6823099)
Nice
Re:Fold the DOM like paper by blahbl4hblahtoo on Saturday November 30, 2013 @06:47AM (#6822905)
It would be awesome if one of these awesome CSS posts would actually test for the features instead of just saying..."IE? SAD TROMBONE FOR YOU!!!!"
Re:Fold the DOM like paper by dmotz on Saturday November 30, 2013 @11:52AM (#6823604)
Author here. OriDomi actually does granular feature tests and has no awareness of what particular browser you're using. While the recent versions of IE do support CSS 3D transforms to a degree, they omit support for the "preserve-3d" transform style which allows the transformations of parent elements to affect their children. Without it, the visual tricks OriDomi does don't work, so the library will disable itself if it finds the client lacks support. Whenever IE begins to support "preserve-3d", OriDomi should start working without modification.
Re:Fold the DOM like paper by blahbl4hblahtoo on Sunday December 01, 2013 @01:48PM (#6828575)
Wow. Thanks for responding. You rock.
Re:Fold the DOM like paper by aram on Saturday November 30, 2013 @06:49AM (#6822910)
Such experiments push the limits - I believe their point is not to make something that works everywhere, at least from the start.
Re:Fold the DOM like paper by frik on Saturday November 30, 2013 @11:25AM (#6823524)
As an IE 11 user I was disappointed too. Sadly, IE 11 still doesn't support the "preserve-3d" property.

http://caniuse.com/#feat=transforms3d

http://stackoverflow.com/questions/19483742/does-ie11-suppor...

Re:Fold the DOM like paper by stefan_kendall on Saturday November 30, 2013 @09:51AM (#6823280)
IE is a cancer. If you can in any way justify cutting off support for IE, you do it. It's a real time and money sink.
Re:Fold the DOM like paper by underwater on Saturday November 30, 2013 @10:35AM (#6823378)
That's a ridiculous statement. Have you even used recent versions of IE?
Re:Fold the DOM like paper by pbhjpbhj on Saturday November 30, 2013 @01:09PM (#6823895)
I've been away from professional web-dev for a while (kids!). My only real experience of IE10 is that I just handled an "IE10 on Win8 only" bug on a friends site so tested with IE10 and IE11 in a virtualised environment. I only have XP installs left of MS Windows.

Of course now that IE is supposed to work they won't let you use the conditional comment targeting method so I must - it seems - break it for IE11 by instructing all IE above 9 to fallback to IE9 compatibility mode.

Nothing else seems to fail with it and applying the hack (IE9 compat mode in a meta-tag) is problematic too.

Has IE changed that much?

That said the site is an application generated mess, it's painful. So maybe IE have really come around.

Re:Fold the DOM like paper by grrowl on Monday December 02, 2013 @05:28AM (#6832881)
Modern IE is nice to use and has reasonable support. It will cost you as much (in dev time) to support as any other browser (or specifically, rendering engine), and its market share is comparable to Firefox.

The problem is old IE. fuck old IE and every bit of its ridiculous, antiquated and outdated self.