Originally published on LinkedIn.
I wanted readers to turn the pages of The Art of AI like a real book. On my laptop the animation looked right. On my phone, parts of the page flashed black.
Several attempts to fix it with Claude Opus 5.5 failed. Working examples found through Clay UI pointed to a better approach, which we proved in an Android emulator and checked on my phone. Opus built the first working prototype, and Fable 5.2 settled it and brought it to the version that is live today.
This article is about how we got from plausible fixes to a page turn that works, and what made the difference.
A book that should turn like paper
The Art of AI is an illustrated book of short reflections on artificial intelligence, published as a website. I prepared the code for the page turn myself, so that a page lifts at the corner, curls softly and settles on the next one. When it broke on my phone, I asked Claude Opus 5.5 to help me fix it.
What I saw on the phone
During a turn, parts of the page went black. Often the whole lower half vanished behind a straight edge under the illustration, and sometimes stripes ran across the paper. A few frames later the page was fine again, so it looked like a flicker. On a computer none of this happened.
This is a screenshot I took on my phone in the middle of a turn. The text is cut off and the left half of the page is simply missing.
Why the AI kept failing
The AI failed several times before it got anywhere. Its first report said: "I couldn't find a single flash frame." It had checked in a desktop browser set to a phone's screen size. That copies the size of a phone, but not its small graphics memory, and that is where the fault lived. Reading the code did not reveal the cause.
My own assumption didn't help. I said it had not flickered before, but the older version broke the same way in an Android emulator. There was no recent change to blame.
The older version in the Android emulator. Stripes and broken paper run across both pages, with the same library and the same pages as before.
The emulator gave shaky answers too: the same unchanged build broke in 17%, 27% and 53% of frames on three runs. So the AI guessed and tested one suspect after another, from shadows and the paper texture to the illustrations and browser hints. None of them fixed it.
Frames from one emulator recording of the live site. Black lower halves, half-drawn pages and stripes appear in different frames of the same turns.
The way out: working examples from Clay UI
The AI failed again and again; the way out came from the patterns in Clay UI, which is open source on GitHub. Clay UI searches catalogs of ready-made interface components and downloads their source code. For a page-flip book it found two working examples: page-flip from Kokonut UI and book-flip from Avara.
What Clay UI does, in under 40 seconds of clay: proven components from real libraries, shaped to your style. Watch the film.
They paid off first on the buttons. Ours switched off during every turn and faded to 42% opacity. Kokonut keeps its buttons on and ignores extra clicks in code, and we did the same.
The controls frame by frame during page turns. In the left column, before the fix, Previous and Next fade out on every turn.
On the pages, the examples changed the question. It stopped being "what is wrong with my page" and became "what do working page turns do differently". In plain words: my version made the phone redraw the whole page again and again during a turn. The working examples draw the page once and then only move that finished image.
For developers: Avara turns a page with a 3D rotation, which the graphics chip can apply to an already painted layer. My library cut the page to a new shape in every frame, so the browser had to repaint it 60 times a second. With a paper texture and a large illustration on every page, the phone ran out of graphics memory, and each missing tile showed as black.
A quick copy of Avara's approach, with rigid pages, removed the black halves, but the page turned like a board. I wanted the soft curl. The patterns gave us the direction; proving it and building it were still ahead.
The key: patterns plus emulation and tests
The patterns inspired a much stricter process. Opus 5.5 limited Chrome's graphics memory in the emulator to 96 MB, a deliberately low setting that imitates a phone under pressure. From then on the bug appeared every time, just as on my phone. Then it ran a control: the same library with plain pages, under the same limit, turned 65 frames without a broken one.
The control run: the same library with plain pages, recorded frame by frame. Every turn draws cleanly.
So in this test the library alone held up. The difference was my heavy pages, painted again in every frame. A memory reading showed that my page held 118 MB of graphics memory even at rest.
The drawing below shows the difference in what the phone has to do in every frame of a turn.
The tests also showed why guessing never worked. Removing one ingredient made the page lighter, but it was still painted again in every frame.
Fable 5.2 settles it
Opus 5.5, guided by the Clay UI patterns, found the direction and built a first prototype: the turn drawn from finished pictures of the pages. In the emulator, under the same low memory limit, we checked 949 animation frames in a row and found no broken one. Fable 5.2 settled the matter and brought it to the version that is live today.
Fable measured the graphics memory and wrote its own page-curl engine on a canvas, a drawing surface inside the browser. A script photographs each of the 86 pages in a fixed phone layout. During a turn the canvas finds the fold line, keeps the front of the page flat and mirrors the back of the paper over the fold, so nothing on the page is painted again. When I opened it on my phone, I wrote back: "It looks very good, I can't see anything breaking."
The comparison below comes from the emulator with the 96 MB limit. The top two rows are the old version and the bottom two the canvas version, turning the same pages.
The last details
The first version showed a picture of the page during a turn and switched back to live text when the turn ended. Every small difference between the two showed as a jump. Fable 5.2 fixed them one by one:
- The chapter 9 title sat on three lines during a turn and on two after it. The line breaks are now recorded with the pictures and forced on the live page.
- After each turn the text got a little thinner and the illustration twitched. The pictures had been taken on a Mac, which draws text bolder than a phone. They are now taken without that, and the picture stays on screen after the turn too, so there is no switch to see.
- A zoomed illustration jumped at the end of closing. It now lands on the picture's exact spot, with matching corners and shadow.
- A page now has to finish turning before the next turn can start.
What made the difference
On its own, AI kept failing on this. Working patterns from Clay UI showed what good page turns do differently, and a detailed process of emulation and tests turned that idea into proof. Opus 5.5 found the direction with them, and Fable 5.2 finished the job. The Clay UI source is on GitHub.
The last part was mine. Our automated checks missed a title that changes lines and text that gets a little thinner. I caught them by reading my own book on my own phone. You can turn its pages at theartofai.behavio.one.







