We will create animated Content Placeholder as React component just like Facebook has when you load the page.

Key points:

1. For each elements on the DOM, you might need to create a placeholder components for that.

2. Different size prop is important

3. CSS animation

.placeholder {
position: relative;
overflow: hidden;
} .placeholder:before {
content: " ";
position: absolute;
top:;
right:;
bottom:;
left:;
background: linear-gradient(
to right,
rgba(255, 255, 255, 0) 0%,
rgba(255, 255, 255, 0.35) 8%,
rgba(255, 255, 255, 0) 16%
);
animation: scanner 0.9s linear infinite;
z-index:;
} @keyframes scanner {
0% {
transform: translateX(-20%);
} 100% {
transform: translateX(170%);
}
} .placeholder__headline {
height: 22px;
background-color: var(--placeholder-color);
margin-bottom: 20px;
} .placeholder__text {
height: 16px;
background-color: var(--placeholder-color);
margin-bottom: 8px;
} .placeholder__image {
border-radius: 50%;
background-color: var(--placeholder-color);
height: 100px;
} .placeholder__text--small {
width: 25%;
} .placeholder__text--medium {
width: 50%;
} .placeholder__text--large {
width: 75%;
} .placeholder__text--block {
width: 100%;
}

Placeholder.jxs:

import React from "react";
import cx from "classnames"; export default function Placeholder({ children, className }) {
return <div className={cx(className, "placeholder")}>{children}</div>;
}
import React from "react";

export default function Image() {
return <div className="placeholder__image" />;
}

[React] Create an Animate Content Placeholder for Loading State in React的更多相关文章

  1. [React] Use CSS Transitions to Avoid a Flash of Loading State

    Based on research at Facebook, we know that if a user sees a flash of loading state, they perceive t ...

  2. React Js之组件(Component)与state

    React Js组件: 组件(Component)是为了更好的维护我们的应用,可以在不影响其他的组件的情况下更新或者更改组件. state:是标记数据的来源,我们使state比较简单和单一,如果我们有 ...

  3. 《React Native 精解与实战》书籍连载「React Native 源码学习方法及其他资源」

    此系列文章将整合我的 React 视频教程与 React Native 书籍中的精华部分,给大家介绍 React Native 源码学习方法及其他资源. 最后的章节给大家介绍 React Native ...

  4. 《React Native 精解与实战》书籍连载「React Native 底层原理」

    此文是我的出版书籍<React Native 精解与实战>连载分享,此书由机械工业出版社出版,书中详解了 React Native 框架底层原理.React Native 组件布局.组件与 ...

  5. 《React Native 精解与实战》书籍连载「React 与 React Native 简介」

    此文是我的出版书籍<React Native 精解与实战>连载分享,此书由机械工业出版社出版,书中详解了 React Native 框架底层原理.React Native 组件布局.组件与 ...

  6. React子组件怎么改变父组件的state

    React子组件怎么改变父组件的state 1.父组件 class Father extends React.Component { construtor(props){ super(props); ...

  7. [Svelte 3] Use await block to wait for a promise and handle loading state in Svelte 3

    Most web applications have to deal with asynchronous data at some point. Svelte 3 apps are no differ ...

  8. React virtual DOM explained in simple English/简单语言解释React的虚拟DOM

    初学React,其中一个很重要的概念是虚拟DOM,看了一篇文章,顺带翻译一下. If you are using React or learning React, you must have hear ...

  9. CSS3效果:animate实现点点点loading动画效果(一)

    实现如图所示的点点点loading效果: 一:CSS3 animation实现代码 html代码: 提交订单中<span class="ani_dot">...< ...

随机推荐

  1. Java中BIO,NIO,AIO的理解

    在高性能的I/O体系设计中,有几个概念常常会使我们感到迷惑不解.具体如下: 1 什么是同步? 2 什么是异步? 3 什么是阻塞? 4 什么是非阻塞? 5 什么是同步阻塞? 6 什么是同步非阻塞? 7  ...

  2. Spring+SpringMVC+MyBatis集成(SSM)

    1.导入需要用到的jar包 <dependencies> <!--Spring核心包--> <dependency> <groupId>org.spri ...

  3. 宁夏网络赛-F-Moving On

    https://www.cnblogs.com/31415926535x/p/11440395.html 一道简单的Floyd题,,但是是动态加点求多次有限制的最短路,,感觉这个思想很好,,当然可以直 ...

  4. T-SQL行列相互转换命令:PIVOT和UNPIVOT使用详解

    最近在维护一个ERP 做二次开发 ,在查找数据源的时候看到前辈写的SQL ,自己能力有限 ,就在网上找找有关这几个关键字的使用方法.做出随笔以做学习之用 T-SQL语句中,PIVOT命令可以实现数据表 ...

  5. 协议——SCCB与IIC的区别

    SCCB(Serial Camera Control Bus,串行摄像头控制总线)是由OV(OmniVision的简称)公司定义和发展的三线式串行总线,该总线控制着摄像头大部分的功能,包括图像数据格式 ...

  6. Android自动化测试之Monkey 转自:LupuX

    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/u011436666/article/details/53998332 在之前的文章Android自动 ...

  7. Linux进程自保护攻防对抗技术研究(Process Kill Technology && Process Protection Against In Linux)

    0. 引言 0x1: Linux系统攻防思想 在linux下进行"进程kill"和"进程保护"的总体思路有以下几个,我们围绕这几个核心思想展开进行研究 . 直接 ...

  8. 解析:让你弄懂redux原理

    作者: HerryLo 本文永久有效链接: https://github.com/AttemptWeb...... Redux是JavaScript状态容器,提供可预测化的状态管理. 在实际开发中,常 ...

  9. 分享大麦UWP版本开发历程-03.GridView或ListView 滚动底部自动加载后续数据

    今天跟大家分享的是大麦UWP客户端,在分类.订单或是搜索时都用到的一个小技巧,技术粗糙大神勿喷. 以大麦分类举例,默认打开的时候,会为用户展示20条数据,当用户滚动鼠标或者使用手势将列表滑动到倒数第二 ...

  10. web API .net - .net core 对比学习-依赖注入

    今天我们来看一下 .net web api 和 .net core web api依赖注入机制的差异. 首先我们分别在.net web api 和 .net core web api新建文件夹Serv ...