惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IT之家
IT之家
Y
Y Combinator Blog
月光博客
月光博客
Blog — PlanetScale
Blog — PlanetScale
GbyAI
GbyAI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
美团技术团队
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
有赞技术团队
有赞技术团队
博客园 - 司徒正美
V
Visual Studio Blog
小众软件
小众软件
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
Tailwind CSS Blog
Apple Machine Learning Research
Apple Machine Learning Research
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
A
About on SuperTechFans
The Cloudflare Blog

CloudCannon Blog

Building with AI: Git-based vs headless vs traditional CMS CloudCannon + Astro: performance meets powerful content management Introducing the Astro Component Starter Introducing Jetstream — built on the Astro Component Starter Why we switched to the system font stack Redesigning CloudCannon’s docs with Diátaxis, Lume, and Pagefind Make content editing more visual: upgraded Editable Regions How Configuration Mode makes building editing interfaces easy Your hosting just got an upgrade (and a price cut) Custom testing domains for professional branding Keep your content consistent with input validation Managing multilingual content in CloudCannon Simplify team publishing with conflict resolution and domain tools Open Beta: Publishing Conflict Resolution Getting started with CloudCannon and Astro: Bookshop, components, and live editing Welcome to the CloudCannon Community! Omnichannel delivery is just marketing spin from API-based CMS companies Getting started with CloudCannon and Astro: Snippets and Collections Managing digital assets in CloudCannon: a guide to smart asset storage Understanding CloudCannon's branching workflows and Projects: a complete guide What is a static website? CloudCannon’s 2024 wrapped Getting started with CloudCannon and Astro: WYSIWYG blogging Jamstack vs. WordPress: reasons to make the change The top five static site generators for 2025 (and when to use them!) Free Jekyll themes for 2025: ten great community options Eleventy (11ty) vs. Hugo How to set up WYSIWYG editing with MkDocs Material The rise of static-first websites: why major brands are making the switch Watching your Core Web Vitals on Jamstack
How Pixelapse image blurring works
2014-11-19 · via CloudCannon Blog

The last deconstruction about the Facebook content placeholder seemed to be popular so here's my next one. I recently discovered a fantastic start up called Pixelapse and the level of polish on their site was outstanding. Today I am doing a deconstruction on something I found there.

What is it? Direct link to this section

As I roamed through the great community designs I noticed the cover images blurred as I scrolled. I immediately thought that they were dynamically blurring images with a canvas but my browser wasn't getting crippled. So I took a look and the result was very pleasing. Here's my clone:

<div class="pixelapse-image">
<div class="the-blurred-image"></div>
<div class="the-nice-crisp-image"></div>
</div>
.the-blurred-image,
.the-nice-crisp-image,
.pixelapse-image
{
width: 100%;
height: 300px;
position: relative;
}

.the-blurred-image,
.the-nice-crisp-image
{
background: url("blurry-golden-gate.jpg") no-repeat center;
background-size: cover; /* This here is why I used divs instead of images */
}

.the-nice-crisp-image {
background-image: url("crisp-golden-gate.jpg");
}

Just two divs with background images, that's amazing and explains the why the performance was so good. I got this one from Pexels which doesn't need attribution but I think they deserve it.

A Nice Crisp Image Direct link to this section

This is the image you want to use, just as you want to show it normally with no blurring. You will be overlaying this over the next image. Here's my one:

A Small Blurred Image Direct link to this section

This is the same image as the one above only I have blurred it. This image will be sitting behind the crisp version and will never change.

The Magic Direct link to this section

Instead of dynamically blurring the image, all it's doing is fading the crisp image in and out. Here's the logic for scrolling:

$(window).on("scroll", function () {
$(".scroll-blurred").each(function () {
var offset = $(this).offset();

// Change top to be the center of the element
offset.top += $(this).outerHeight() / 2;

// Get the center of the screen
var centerOfTheScreen = window.scrollY + $(window).height() / 2;

// Check the distance between the center of the screen and out images
var distanceFromCenter = Math.abs(centerOfTheScreen - offset.top);

// Calculate the opacity with {BLUR_RANGE} pixels away being 1
var opacity = Math.min(distanceFromCenter, BLUR_RANGE) / BLUR_RANGE;

// Set the opacity (inverse last calculation so that it
// fades in as you approach the center)
$(this).find(".the-nice-crisp-image").css("opacity", 1 - opacity);
});
});

This is a version using jQuery so I can demonstrate the logic cleanly. To optimise this you should debounce the scroll events by using requestAnimationFrame.

To demonstrate the the same effect, Below is a pure CSS implementation using the hover state and some nice CSS transitions (try hovering). I reversed the effect so the default is the crisp image, added a glow and added a greeting.

.do-it-on-hover-instead .the-blurred-image,
.do-it-on-hover-instead .the-nice-crisp-image
{
opacity: 0.7;
transition: all 0.9s ease-in-out;
}

.do-it-on-hover-instead:hover .the-nice-crisp-image {
opacity: 0;
}

.do-it-on-hover-instead:hover .the-blurred-image {
box-shadow: inset 0 0 30px #C89F69;
}

Why would I ever use this? Direct link to this section

This is a great way for setting the focus on the hovered element and one that people will remember. The other way I would use this same effect is so that I can load the blurred version with a lower resolution then preload the larger crisp image over the top. The user doesn't necessarily suffer as the image is loading and can still use the site as it loads.

That's it Direct link to this section

This was a clever way to polish the UI without impacting on the performance of the page. This fits the tune of the rest of Pixelapse which is beautifully polished. Definitely worth checking out for the idea and the designs. If you found this useful or have any questions feel free to comment below.

Note: I used unprefixed CSS in the code examples to keep it clean. You can use Our CSS Prefixer to get cross a cross browser version.