dmotz / oriDomi

🪭 Fold up DOM elements like paper

Home Page:http://oridomi.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Oridomi folds to back rather staying in front

besi opened this issue · comments

commented

Whenever I completely unfold my div the outer bit then folds behind the inner part thus hiding behind it.

This can be reproduced like so:

  1. Use an accordion fold
  2. Completely unfold it
  3. Now rather than folding back to where "it came from" the fold goes behind.

It's also possible with the example in the website:

image

Is there a way to prevent this behavior?

commented

My example after completely unfolding the div:

Rather than this (fold vefore)
image

It does this (fold behind)
image

In order to fold to the correct angle based on the movement of the mouse/finger, oriDomi has to know which side of zero the last operation was on. When you fold the element back to zero with your mouse/touch, the last operation is saved as being positive and subsequent mouse movements will fold with the angle on the positive side of zero.

In the current version this is decided here:
https://github.com/dmotz/oriDomi/blob/master/oridomi.coffee#L609

In the next version I'm adding a way to constrain the range of angles, so the user can only fold a certain amount with the mouse/touch. Until then, you could add a hack to get your desired outcome (not folding back when zero is hit) by changing the conditional here:
https://github.com/dmotz/oriDomi/blob/master/oridomi.coffee#L814

commented

I am using the oridomi.coffee now, rather than the minified version and I was able to fix my problem by chaniging

this

@lastOp = method: method, options: options, negative: angle < 0

to this

@lastOp = method: method, options: options, negative: true

Thanks for your help!