Web-Slinger.css began life as a pure CSS stand-in for Wow.js, triggering one-way animations as elements scroll into view. The library is built around the scroll-trigger-n class convention, the only real user-facing surface it exposes. It works fine for vertical reading order, but cards that should react to a horizontal swipe need patching, because horizontal movement was never part of its design.
Turning the library sideways
The first step is to override the timeline axis for trigger markers so their animations resolve against horizontal scroll rather than the vertical default:
[class^="scroll-trigger-"] {
view-timeline-axis: x;
}
Without that patch, every trigger fires immediately. The cards are out of horizontal view, but vertically they sit above the fold, so the default timeline considers them revealed at load.
For the swiper foundation, we started from Nikolay Talanov's JavaScript Tinder demo, removed all but one card and all of the JavaScript, then imported Web-Slinger.css with the horizontal patch. The card container became position: fixed, and three scroll-snapping boxes were placed side by side, each sized to the viewport. The middle slide carries scroll-align: center, so the user begins in the center with the option of scrolling in either direction. The interface shown below is currently limited to Chrome and Edge.
A useful frame for this kind of work: the scrollable element does not have to scroll anything visibly. It is the same trade as the checkbox hack, where the checkbox itself is hidden and only its CSS-driven behavior is used. We want the mechanics, not the default UI.
Swipe left
Rejection attached to a marker on the third slide:
<div class="demo__card on-scroll-trigger-1 reject">
<!-- HTML for the card -->
</div>
<main>
<div class="slide">
</div>
<div id="middle" class="slide">
</div>
<div class="slide">
<div class="scroll-trigger-1"></div>
</div>
</main>
Swipe right, and the bug
Liking was implemented along the same lines:
<div class="on-scroll-trigger-2 accept">
<div class="demo__card on-scroll-trigger-2 reject">
<!-- HTML for the card -->
</div>
</div>
<main>
<div class="slide">
<div class="scroll-trigger-2"></div>
</div>
<div id="middle" class="slide">
</div>
<div class="slide">
<div class="scroll-trigger-1"></div>
</div>
</main>
The result is that the card is "liked" the moment the page loads, with no user input. That is not the intended behavior for the positive swipe.
The cause is what view-timeline was and was not designed to express. Its subject advances the animation once it has crossed the viewport along the scrolling direction. The visualizer for animation-range makes this clear: whatever range you pick, the subject wants to complete its animation after it has passed the viewport, which is the opposite of what a backwards-triggered animation needs. Web-Slinger.css was built on the assumption that animations move forward with scroll.
Using scroll direction to correct the trigger
Bramus of the Chrome Developer Team has a demo that detects scroll direction in CSS via a --scroll-direction custom property. Combined with a style query, that property keeps .scroll-trigger-2 out of the picture until it is actually reached:
:root {
animation: adjust-slide-index 3s steps(3, end), adjust-pos 1s;
animation-timeline: scroll(root x);
}
@property --slide-index {
syntax: "<number>";
inherits: true;
initial-value: 0;
}
@keyframes adjust-slide-index {
to {
--slide-index: 3;
}
}
.scroll-trigger-2 {
display: none;
}
@container style(--scroll-direction: -1) and style(--slide-index: 0) {
.scroll-trigger-2 {
display: block;
}
}
The marker with the .scroll-trigger-2 class is therefore not rendered until the user is on the previous slide and arrives by scrolling backward. The snippet also introduces --slide-index, driven by a three-second, three-step scroll-driven animation that tracks the current slide. It is what makes the swipe decisive: a small nudge should not register a dislike.
Tabulating the verdict
The tally of readers who dislike Spider Pig against those who don't is collected with a third-party counter image used as the background of the card underneath it. The service is external and old, but free, and it stays as long as it keeps responding.
@container style(--scroll-trigger-1: 1) {
.result {
background-image: url('https://counter6.optistats.ovh/private/freecounterstat.php?c=qbgw71kxx1stgsf5shmwrb2aflk5wecz');
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
}
.counter-description::after {
content: 'who like spider pig';
}
.scroll-trigger-2 {
display: none;
}
}
@container style(--scroll-trigger-2: 1) {
.result {
background-image: url('https://counter6.optistats.ovh/private/freecounterstat.php?c=abtwsn99snah6wq42nhnsmbp6pxbrwtj');
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
}
.counter-description::after {
content: 'who dislike spider pig';
}
.scroll-trigger-1 {
display: none;
}
}
What the experiment showed
The trickier part was implementing animations that only run when a user scrolls backward to meet an element. That direction contradicts an assumption baked into the current API, and the workaround reflects it. What the spec does demonstrate is how much can be expressed through styling hooks tied to specific scroll behaviors, provided you are willing to hack them into place. It would be better if the spec allowed the swipe-right trigger to work as it intuitively should:
[class^="scroll-trigger-"] {
view-timeline-axis: x;
view-timeline-direction: backwards; /* <-- this is speculative. do not use! */
}
With such an API, no patch would be needed. What is still missing is broader browser support for scroll-driven animations, and beyond that, more flexibility in the spec itself, so designers can build nonlinear narratives into their experiences. Failing that, once animation timelines reach more browsers, Web-Slinger.css may be worth making more complete and production-ready, bringing its advanced scrolling use cases within reach of the average CSS user.



