Day 38/100 X: Blurry load
As frontend developers, we also need to take care of those instances in which the website has not been properly displayed yet. In other words, I am talking about taking care of the loading of the page.
A few weeks ago I came across an ice cream website that featured a loading that went from a totally blurred image through a totally clear one. I figured I could copy this trick in order to practice my CSS skills.
To achieve this, one needs to think about what makes a picture blurry in the first place. The obvious value one could use is blur(), so we need to make it progress from totally blurry to finally clear:
function blurring() {
load++
if(load > 99) {
clearInterval(int)
}
loadText.innerText = `${load}%`
loadText.style.opacity = scale(load, 0, 100, 1, 0)
bg.style.filter = `blur(${scale(load, 0, 100, 30, 0)}px)`
}
The same counter variable that will make the picture clearer can also be used to feature the progress of the loading, which we have named “load”.
Comments
Post a Comment