flak rss random

zeno scrolling

Zeno scrolling requires javascript.

Everybody loves infinite scrolling.

Which is to say everybody hates it, but we love to use it anyway.

There’s just one problem. Infinite scrolling requires infinite data.

What if we don’t have that much content? Or what if we are old school enough to still care about bandwidth?

I have just the thing. Zeno scrolling. Infinite scrolling with finite data.

You read half the content. You’re going to read the second half of the content next.

But now the content is bigger. You scroll some more. The content gets bigger again.

In order to get to the second half you have to get past the first half.

It may be a little annoying to the user never reaching the end. But that’s no different than before, right?

On the plus side, as a site operator, I can make more economical use of my limited content.

Progress is an illusion.

There is no Zuul, only Zeno.

(Script is no longer inlined.)

var scroller = document.scrollingElement
var el = document.getElementsByClassName("post")[0]
var lh = 1
var fs = 2
var scrollit
function fixer() {
        var h = scroller.scrollHeight
        scroller.scrollTop = h * 0.4
        setTimeout(scrollit, 1000)
}
scrollit =  function() {
        var h = scroller.scrollHeight
        var t = scroller.scrollTop
        var p = t / h
        var r = scroller.scrollHeight / scroller.clientHeight
        var adjust = p > 0.5 || r < 2
        var withfix = p > 0.5
        if (adjust) {
                console.log("adjusting")
                fs *= 1.5
                el.style.fontSize = fs + "em"
                lh *= 1.5
                el.style.lineHeight = lh + "em"
        }
        if (withfix) {
                setTimeout(fixer, 1)
        } else {
                setTimeout(scrollit, 1000)
        }
}
el.style.fontSize = fs + "em"
el.style.lineHeight = lh + "em"
setTimeout(scrollit, 1)

Posted 01 Nov 2018 18:52 by tedu Updated: 01 May 2022 06:16
Tagged: javascript web