正在加载视频...

视频加载失败

Stream a live image of any element into a canvas <ElementMirror source={cardRef} fps={30} /> Good for things like blurred img/video backdrops, dnd, pip, minimaps, magnifiers, custom glass effects, creative coding shenanigans

17,171 次观看 • 2 个月前 •via X (Twitter)

25 条评论

Lorenzo Dossi 的头像
Lorenzo Dossi2 个月前

This is so good, would be cool to skew the reflection a bit probably

Austin Malerba 的头像
Austin Malerba2 个月前

Yeee and maybe some sort of horizon line. Def a lil something missing🤔

Artur Bień 的头像
Artur Bień2 个月前

So goood. How does it render dom to the canvas under the hood? 👀

Austin Malerba 的头像
Austin Malerba2 个月前

Through a lib called snapdom that I forked and optimized a bit for this use case html-in-canvas will probably eventually be the more appropriate way but obvs browser support issues for now. Gets pretty tricky/interesting when you consider layout size vs rendered size and what happens with things like shadows/rotations which cause pixels to get painted outside of the element’s box and therefore clipped by canvas if not careful

rauno 的头像
rauno2 个月前

so nice

Majo Puterka 的头像
Majo Puterka2 个月前

Slightly distracting but beautiful effect!

Bakemono (Fra) 👹 的头像
Bakemono (Fra) 👹2 个月前

Smoooth

Albert Zhang 的头像
Albert Zhang2 个月前

Oh this is useful. I’ve needed a tiny live preview like this before.

Jason Festa 的头像
Jason Festa2 个月前

that mirror

RobIW 的头像
RobIW2 个月前

This looks sick I gotta give this a try

Mars (parody) 的头像
Mars (parody)2 个月前

was just trying to do this with HTML in Canvas but had some snags, does this require permissions prompt?

Austin Malerba 的头像
Austin Malerba2 个月前

Haven’t hit any permissions issues yet, and yes I feel like html-in-canvas will eventually be the cleaner way to do this but for now browser support’s obviously a bit of a blocker there

Chase Davis 的头像
Chase Davis2 个月前

Yes!

Tihomir Valkanov 的头像
Tihomir Valkanov2 个月前

this is sooo smooth!!! WoW!!!

shegtory 的头像
shegtory2 个月前

finally sth worth to stop scrolling timeline

Griz 的头像
Griz2 个月前

blurred backdrops finally stop being screenshots

Karime 的头像
Karime2 个月前

So good !

insan 的头像
insan2 个月前

fps=30 smooth=yes optimised=somewhat controls=scrollwheel

Rakibul 的头像
Rakibul2 个月前

looks super clean

modi 的头像
modi2 个月前

the minimap / magnifier use cases are sick

SnapDOM 的头像
SnapDOM2 个月前

Excellent work Austin! You are welcome to propose a PR at SnapDOM with your findings

miheretab samson 的头像
miheretab samson2 个月前

cool interaction , but wont it take much space

Austin Malerba 的头像
Austin Malerba2 个月前

Depends on the size of element, pixel ratio and frame rate but yeah if not careful then can hit cpu+memory pretty hard

Shifat Masud 的头像
Shifat Masud2 个月前

How do you capture interactions like you did? Snapshot per moments? Please tell me the logic

Austin Malerba 的头像
Austin Malerba2 个月前

Yes capture snapshots with a forked version of snapdom at the specified frame rate and then set up so that multiple mirrors on same source all share the same snapshots rather than each snapshotting again. Code is linked in the post

相关视频