Open to work

How I Built a Work Page You Can Drag in Any Direction

Most portfolio work pages are grids. They are clear, but they feel like a spreadsheet. I wanted my work to feel like a table covered in printed covers that you can push around with your hand. Both of my sites now have it: nikhildadhich.com/work and nikhildadhich.si/work. Thirty-three projects, 25 web apps and 8 brand projects, on a table that never ends.

Dragging the table on nikhildadhich.si/work: the cards tilt with the speed and light up when you point at one.

How can a table never end?

There is only one set of cards. They are laid out on a tile that is bigger than the screen, in a loose grid with a little random offset and rotation so it looks placed by hand. When you drag, the whole tile moves. Each card's position is its place on the tile plus the drag offset, wrapped with a modulo by the tile's width and height. A card that leaves the left edge comes back on the right. No copies, no loading more, and the layout is the same on every visit.

How does it feel physical?

Three small rules. When you let go, the table keeps the speed of your last movement and slows down a little every frame, like something sliding on a surface. If you held still before letting go, it stops dead instead of flinging. When nobody touches it for a few seconds, it drifts slowly, so the page never looks frozen.

The cards also tilt in the direction you drag. The tilt is eased towards its target instead of jumping to it, which is the difference between a table that sways and one that shakes.

Why are the covers grey?

With 33 colourful covers on screen, nothing stands out. So every cover is grey until you point at it. Then it comes to life in full colour, lifts a little and gets a frame. Your attention goes where your pointer is.

There is also a small counter: "Seen 07 / 33". It counts the cards that pass through the middle of the screen. It is a tiny game, but it rewards exploring the whole table instead of the first row.

What made it jerky, and how did I fix it?

The first version worked, but dragging was not smooth. The cause was not the cards. It was everything around them repainting every frame:

  • A moving background pattern. The dot grid was moved with a background position, which repaints the full screen. Now the dots are their own layer, moved with a transform by at most 30 pixels and wrapped.
  • A CSS variable on the page root. The soft light that follows the pointer set a variable on the whole page at every mouse move, so the browser checked the styles of every element. Now the light is a circle moved with a transform.
  • Blur behind floating buttons. A frosted background over moving content has to be blurred again every frame. The buttons now have a solid dark background.
  • Hover effects while moving. Cards passing under a still cursor kept switching their hover colour and shadow. While the table moves, hover effects pause.

The rule I keep: during an animation, change only transforms and opacity. Everything else waits.

How do you scroll a page that contains a canvas?

On nikhildadhich.si the table fills the screen, so the mouse wheel simply moves it. On nikhildadhich.com it sits inside a normal page with text above and below, and that is harder. If the wheel always moved the table, people scrolling down the page would get stuck in it.

So the wheel moves the table only when the whole table is on screen and the page has stopped scrolling. Move the mouse off the table and the page scrolls again. On a phone, a sideways swipe moves the table and an up-and-down swipe scrolls the page.

Not everyone wants to drag

A canvas is fun, not always efficient. So there is a List view with large names, where a cover follows the cursor, and on nikhildadhich.com a Grid view with full cards. The filters work in every view. Pressing Tab moves through the cards and brings each one to the middle of the table. With reduced motion turned on, there is no drift and no tilt.

Key takeaways

  • An endless canvas needs only one tile and a modulo, not copies.
  • Momentum, a stop on a still release and an eased tilt make it feel physical.
  • Grey by default, colour on focus: guide attention in a busy layout.
  • During animation, change only transforms and opacity.
  • Always offer a calm way to see the same work: a list and filters.

Questions

Questions

Does the canvas use a library?

No. It is plain JavaScript and CSS: each card is moved with a CSS transform every frame, and the wrap-around is a modulo of the card position by the size of one tile.

What if a visitor does not want to drag?

There is a List view with large names and a Grid view on nikhildadhich.com, the filters work in every view, Tab brings each card to the middle, and with reduced motion turned on there is no drift and no tilt.

Why did the first version feel jerky?

Some things repainted the whole screen every frame: a moving background pattern, a CSS variable on the page root, blur behind floating buttons and hover effects on cards passing under the cursor. Moving only transforms fixed it.

Nikhil Dadhich

Nikhil Dadhich is an AI Creative Technologist in Jaipur, India. He designs and builds AI image and video production workflows, creative automation and web apps, with a background in graphic design, UI/UX and motion since 2017. More about me.