Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
`left: calc(...)` based on order? (Math, Carl, math!) It's faint, but if you assign --order variable through JS, it may be a piece of cake!
Let Angular assign `style="--order: ... "` to each item in a loop. -
Also, why not `border-radius` for the arc? Yeah, it will be a circle at first, but if you enlarge and clip it (via `overflow: hidden` in parent containet), no SVG is needed.
-
@Hypehn ohoho, but what if I say that approaches are drastically different? You should also account for the pivot point of item you try to align (it's top-left). I'm starting to think that `transform: translateX(...)` is better fit, instead of margins and "physical" positioning.
-
@Hypehn Whatever you do, just remember that CSS Variables are your friends. It's a relief for both maintenance and separation of concerns!
-
@Hypehn heh, no problem!
Have a look at that, they even learned how to do sine and cosine with CSS, this is dope: https://gist.github.com/stereokai/...
Convert the item's order to an angle and it will be precise enough. -
@Hypehn it was fun to solve, I even learned few things 👍 For example, now I imagine how to implement a juicy animation with items appearing one by one from the center.
First, you position all items in the same center, then multiply radius on cosine/sine for translateX/Y respectively. Last stage is to animate radius and employ animation-delay that depends on order. -
If you want to do it with other curves than arcs of circles, you could generalize it using parametric equations.
Related Rants
I need to position circles on a curve in a HTML page, the number of circles can be variable (a minimum of 3 and a maximum of 7) and these should be spaced equally. Each circle is a clickable element that has some functionality, and also just hovering on these circles should show a thumbnail right beside them.
https://i.stack.imgur.com/jC3gE.png
As shown in the above image. The whole design consists of 2 of these curves one on the left and one on the right(I cannot put the whole design here sorry) one approach I can think of is rendering the curve as an SVG and then position the beads (circles) on them but I cannot think of any way to position those elements exactly on the svg. Any kind of help or code which achieves this functionality is a huge help.
Note: I am using Angular, if there's a nice way to do the same in Angular I'd be pretty delighted. I know that this isn't the right place to ask this but any help would be greatly appreciated.
Thanks in Advance
question
angular
html
css