Given:

- S - height of container
- k - height of zone where badges are shown without folding (k < S)
- h - height of a badge (h < k)
- n - amount of badges

Problem:

Find top (

**y**?) position of each**t**badge (t in [0..(n-1)]) if the list scrolled by**q**factor (q in [0;n*h-k] where 0 - means showing top badges without folding, n*h-k - means showing bottom badges without folding)
Solution:

We need an interpolator function f(x) which is

- Is defined in [0;1] and rising
- f(0) = 0
- f(1) = 1

This function defines how badges are folded

Good example of such function is f(x) = x*x

Calculation

v = n*h-k

z = t*h

p = q/v

p = q/v

alpha = (S-k)/(f(p)+f(1-p))

Then

1. y = alpha * f(z/v) if z < q

2. y = z + alpha * f(p) - vp if z >= q and z <= q+k

3. y = S - alpha * f((n*h-z)/v) if z > q + k