Skip to content

Commit 78b7bdc

Browse files
committed
add animation bar to show the blocking in main thread
1 parent eb2060f commit 78b7bdc

File tree

5 files changed

+43
-0
lines changed

5 files changed

+43
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.container {
2+
position: relative;
3+
width: 100%;
4+
height: 8px;
5+
overflow: hidden;
6+
}
7+
.bar {
8+
position: absolute;
9+
top: 0;
10+
left: 0;
11+
height: 8px;
12+
background-color: #1212ff;
13+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<template>
2+
<div class="container">
3+
<div class="bar" style={barStyle}></div>
4+
</div>
5+
</template>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { LightningElement } from "lwc";
2+
3+
export default class MyAnimationBar extends LightningElement {
4+
barStart = 0;
5+
barSize = 50;
6+
7+
get barStyle() {
8+
return `left: ${this.barStart}%; width: ${this.barSize}%;`;
9+
}
10+
11+
connectedCallback() {
12+
const updateBar = () => {
13+
this.barStart = (this.barStart + 1) % 100;
14+
this.barSize = (this.barSize + 2) % 80;
15+
requestAnimationFrame(updateBar);
16+
};
17+
requestAnimationFrame(updateBar);
18+
}
19+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
3+
<apiVersion>49.0</apiVersion>
4+
<isExposed>false</isExposed>
5+
</LightningComponentBundle>

force-app/example/default/lwc/myWebWorkerCmp/myWebWorkerCmp.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<template>
22
<div class="slds-p-around_medium">
3+
<c-my-animation-bar></c-my-animation-bar>
34
<lightning-input
45
label="Input Number"
56
type="number"

0 commit comments

Comments
 (0)