Chris’ Nook: Excellent & Helpful Concepts

Chris’ Nook: Excellent & Helpful Concepts

[ad_1]

I used to be ogling the speculation of Go out Animations just lately, this is, a up to date proposal for (one thing like) @exit-style which might let us animate components as we take away them from the DOM. That is in large part simply an offer these days, with many demanding situations forward.

However there may be new tech that is helping with go out (and front!) animations presently (in Chrome, anyway). They’re some reasonably new issues that, for those who’re like me, don’t pop to thoughts in an instant simply but after we’re in those DOM input/go out eventualities. Una Kravets and Joey Arhar coated them in a nice weblog submit again in August: 4 new CSS options for easy access and go out animations. Permit me to summarize!

  1. When you’re the usage of a @keyframes animation, you’ll be able to now set the show belongings anyplace inside of it and it’ll turn at that keyframe. It didn’t use to be like this. Animations would in an instant transfer the show belongings to the overall price. This makes “go out” animations the place the last thing you do is ready show: none, which eliminates the part from view and the accessibility tree, very probable with @keyframes.
  2. When you’re the usage of transition, alternatively, the show belongings nonetheless right away flips to the overall price. This is, until you employ the brand new transition-behavior: allow-discrete; belongings/price which flips it in order that show adjustments on the finish of a transition as an alternative of the start.
  3. The ones first two are lovely darn at hand for go out animations (they don’t assist with leaving-DOM eventualities, however are nonetheless “exits” of a type). However for front or “beginning” animations, when a component is added to the DOM, now we now have @starting-style that permits us to set some kinds which then in an instant transition to the kinds set at the part out of doors of that at-rule, assuming they’re provide.
  4. Commonplace HTML components that you can think of having entrances and exists are <conversation> and any part behaving as a “popover” (like a menu or tooltip). Those components take pleasure in being magically transported to a “best layer”, that means much less twiddling with z-index and stacking context issues and such. However now, if making a decision to animate the transitions out and in of visibility, with a view to make that occur easily, you wish to have so as to add a brand new key phrase overlay on your transitions. Hello, from time to time you gotta do extra paintings to have great issues.
Chris’ Nook: Excellent & Helpful Concepts

And all of that doesn’t even get into View Transitions. View Transitions can in fact assist with “actual” go out animations, in order that’s price a glance for those who’re in that state of affairs. Una and Joey do duvet that, so indisputably dig into that weblog submit.


You understand how some analytics gear can observe clicks on outgoing hyperlinks on web pages? That all the time boggled my thoughts. To ensure that the analytics device to understand that, it must shoot that knowledge to a server within the tiny break up 2d of time earlier than the web site is long past and changed with the brand new one on the hyperlink the consumer adopted. I simply think this is moderately unreliable.

There may be in fact a internet platform API this is in particular designed for this “simply earlier than a consumer leaves” state of affairs: navigator.sendBeacon(). That’s great to have, however you continue to need to name it, and phone it on the proper time. Erik Witt researched this within the weblog submit Sell off Beacon Reliability: Benchmarking Methods for Minimum Information Loss.

He in comparison calling sendBeacon in an match listener for sell off, beforeunload, pagehide, and visibilitychange. I might have put my cash on beforeunload, however that used to be by way of a ways the worst reporting handiest 37% of information reliably. The most productive of the 4 is visibilitychange at 90%. Erik additionally covers an experimental API in Chrome this is reporting 98% so take a look at the submit for that (it additionally appears just a little more uncomplicated to make use of).


Now and again, I see an AI/LLM API instance that I’m like OK high-quality that’s lovely artful. I assumed that after studying Raymond Camden’s Can GenAI will let you win in Vegas? As Raymond says, uh, no, it may possibly’t, however it permit you to make the best-possible determination at a recreation like Blackjack that has a somewhat complicated determination tree.

In fact what it’s essential to/will have to do, for those who had been going to put in writing device that will help you with Blackjack, is have the device go back the proper end result from the information in that tree. However there’s something extra a laugh and futuristic about asking an LLM for the solution as an alternative. Like speaking to a pc on your ear.

I’m taking part in blackjack and the broker has a six of diamonds appearing. I’ve were given a jack of golf equipment and a jack of hearts. Must I hit or will have to I keep?

You have got 20, which is a superb hand. The broker has 16, which is under the typical. When you hit, you chance getting a card that may bust you. So it’s higher to stick and hope that the broker busts.

Once more this isn’t a excellent concept, as a result of as Raymond struggled during the AI used to be more than pleased to equipped terrible solutions, however there’s something fascinating about crafting the urged to get the finest effects and getting the ends up in “undeniable language” manner that feels much less uninteresting than coordinates off a chart.


A Discord I’m in used to be chatting it up the opposite day a few fresh Kevin Powell video: A brand new technique to container and wrapper categories (he credit a handful of others). The speculation used to be putting in a grid with columns like this:

.grid {
  show: grid;
  grid-template-columns:
    [full-width-start] minmax(var(--padding-inline), 1fr)
    [breakout-start] minmax(0, var(--breakout-size))
    [content-start] min(
      100% - (var(--padding-inline) * 2),
      var(--content-max-width)
    )
    [content-end]
    minmax(0, var(--breakout-size)) [breakout-end]
    minmax(var(--padding-inline), 1fr) [full-width-end];
}

Kinda sophisticated taking a look proper? Damaged down into steps it’s in point of fact now not that dangerous, it’s most commonly the naming-things that makes it seem like so much. However the actual great thing about it’s in the naming. With this in position, you’ll be able to very simply position an merchandise edge-to-edge at the grid by way of simply calling grid-column: full-width;, however common content material is ready within the heart. There are some great main points to pick out up within the video. In all probability the finest of which is how you’ll be able to set the content material inside of a full-width container again to the similar heart content material house by way of making use of the very same template columns to that container.


Anything else layout-related that calls for JavaScript I normally side-eye lovely laborious. The speculation of structure failing, and even moving, when JavaScript so much (or doesn’t) simply bothers me.

However from time to time, when the structure updating is fully an advantage enhancement, I relent. I feel I could be there with Yihui Xie’s concept for making components “complete width” (like the category names Kevin makes to be had within the phase above).

The speculation is that you’ll be able to use slightly little bit of JavaScript to dynamically make a decision if a component will have to be complete width or now not. Listed here are the eventualities:

  1. Code blocks (<pre><code>).If the scrollWidth is larger than offsetWidth, it method the code block has a horizontal scrollbar, and we might need to make it full-width.
  2. Tables (<desk>).If its offsetWidth is larger than its guardian’s offsetWidth, it’s too broad.
  3. Desk of contents (a component that has the ID TableOfContents, e.g., <nav identification="TableOfContents">).If any TOC merchandise has more than one rectangles at the structure (getClientRects().period > 1), it method the article is wrapped, and the TOC might take pleasure in extra space.

If the weather develop into full-width, nice, it’s a most likely enhancement, but when they don’t, it’s now not a large deal.

Yihui Xie does the full-width-ing with a category like this:

.fullwidth {
  width: 100vw;
  margin-left: calc(50% - 50vw);
}

Which could also be a vintage method, however I’d say isn’t somewhat as powerful or versatile because the above tactics.


Say you sought after to trace web page perspectives on a website online, however very a lot need to keep away from any bots. This is, anything else inquiring for your website online that isn’t an actual lifestyles human consumer. Herman Martinus is making an attempt that together with his Endure running a blog platform like this:

frame:hover {
  border-image: url("/hit/{{ submit.identification }}/?ref={{ request.META.HTTP_REFERER }}");
}

Now, when an individual hovers their cursor over the web page (or scrolls on cell) it triggers frame:hover which calls the URL for the submit hit. I don’t suppose any bots hover and as an alternative simply use JS to engage with the web page, so I will, with cheap simple task, think that it is a human reader.

I then verify the user-agent isn’t a bot (which isn’t easiest, however nonetheless one thing). I additionally extract the browser and platform from the user-agent string.

In all probability now not rigorous laptop science however I wager it’s much more helpful quantity than only a server aspect counter.

[ad_2]

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back To Top
0
Would love your thoughts, please comment.x
()
x