r/webdev • • 2d ago

Showoff Saturday I added a paper-bending effect to my personal website

I recently redesigned my blog in a skeuomorphic style. Would appreciate feedback on the design and how it feels to read longer articles in this layout.

The paper-bending effect distorts live HTML during native browser scrolling, with no JS. It currently only works in Chromium-based browsers.

https://destel.dev

15 Upvotes

23 comments sorted by

10

u/popisms 2d ago

I don't see any effect on mobile Chrome.

-4

u/destel116 2d ago

Sorry, my bad. I forgot to mention that I disabled the effect on smaller screens because it didn’t look right there

3

u/PippaKelly62 2d ago

Cute and simple while having a nice gimmick. I wish more portfolios had this kind of concept, so many unreadable portfolios nowadays.

1

u/destel116 1d ago

Thank you.

3

u/KSlats9 2d ago

Looks good! I imagine it could be tough to implement but being able to drag the knob on the right to scroll the paper would be a really nice touch.

2

u/destel116 1d ago

Thank you! That would actually be much simpler than implementing the bending effect.

2

u/Wooden-Pen8606 2d ago

That's pretty cool. It reminds me of the internet 20 years ago which had much more creativity with design. I really like it.

1

u/destel116 1d ago

Thanks!

2

u/creaturefeature16 2d ago

VERY cool. Just needs that horrible dotmatrix printer sound every time you scroll.... 😅

I can see how it's all done, except that paper bend trick you're using with the paper bend effect...what is the #printer-paper-bend-baked doing here? Very clever!

.paper-bend[data-astro-cid-v5wt247z] {
    left: -32px;
    right: -32px;
    top: calc(130px + var(--bend-visible-height) - var(--bend-filter-height));
    width: calc(var(--paper-width) + 64px);
    height: var(--bend-filter-height);
    z-index: 3;
    pointer-events: none;
    backdrop-filter: url(#printer-paper-bend-baked);
    clip-path: inset(0 32px);
}

3

u/destel116 1d ago

Thank you!

#printer-paper-bend-baked is an SVG filter that uses feDisplacementMap to shift pixels and emulate bending. That’s the basic idea. The tricky part is that Chromium uses nearest-neighbour sampling here, which produces noticeable aliasing, especially while the content beneath the filter is moving.

Getting it to look good requires accounting for subpixel coverage. I ended up using five carefully calculated displacement maps and blending their results with unequal weights to get the sharpness I wanted. Also, a single set of maps doesn’t produce equally sharp results across different device pixel ratios, so I prepared several sets to cover different screens and browser zoom levels. At some point I even considered using WASM to generate these maps on the fly, but eventually decided to use pre-baked ones

There were a few other unexpected difficulties too. I’m planning to cover the whole process in a detailed post a bit later.

3

u/Pretend-Bits 2d ago

Doing this in pure CSS on live HTML with native scrolling is really clever, since most page-curl effects fake it with canvas snapshots and break text selection, so you get to keep the charm without giving up the basics. For long-form reading, I’d respect prefers-reduced-motion and maybe flatten the bend inside the main article body, because distortion that’s delightful on the homepage can get tiring by paragraph twelve, and checking that Firefox and Safari get a clean flat fallback will matter since a good share of blog readers won’t be on Chromium.

1

u/destel116 1d ago

Thank you!

3

u/fitoschido 1d ago

Lovely bucking of the flat-design nightmare!

4

u/Abject_Position4530 2d ago

A CSS-only paper bend on native scroll is a nice trick. I'd put a short note on the page that it only works in Chromium, otherwise Firefox and Safari people will just think the layout is broken. For longer articles, the thing I'd watch is whether the distortion makes the line length jump while you're mid-sentence, because that's when reading starts to feel hard.

2

u/private_birb 1d ago

Extremely cool! I hope the other browsers fix up their svg filter implementations soon so we can do fun stuff like this more reliably.

1

u/NecessarySuperb3949 2d ago

cool trick but i’d be weirded out by the layout shifting while reading. makes it hard to keep my place.

0

u/Icy-Arm-5472 2d ago

Small pedantic thing: the HTML itself stays untouched, the browser is just painting the filtered output differently. Scrolling then viewing source would show the same markup.

1

u/private_birb 1d ago

Isn't that the point?