Skip to content

Commit ba30939

Browse files
committed
[frontend] download icon animation
1 parent c047134 commit ba30939

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

frontend/src/Browser.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { focusOmnibox } from "./components/UrlInput";
88

99
import * as tldts from "tldts";
1010
import { scramjet } from "./main";
11+
import { animateDownloadFly } from "./components/Omnibox";
1112
export const pushTab = createDelegate<Tab>();
1213
export const popTab = createDelegate<Tab>();
1314
export const forceScreenshot = createDelegate<Tab>();
@@ -99,6 +100,7 @@ export class Browser extends StatefulClass {
99100
) {
100101
this.downloadProgress = 0.1;
101102
let downloaded = 0;
103+
animateDownloadFly();
102104
await body.pipeTo(
103105
new WritableStream({
104106
write(chunk) {

frontend/src/components/Omnibox.tsx

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import { createDelegate } from "dreamland/core";
1111
import type { Tab } from "../Tab";
1212
import { UrlInput } from "./UrlInput";
1313
import { browser } from "../Browser";
14+
import { Icon } from "./Icon";
15+
16+
export const animateDownloadFly = createDelegate<void>();
1417

1518
export const Spacer: Component = function (cx) {
1619
return <div></div>;
@@ -116,6 +119,20 @@ export const Omnibox: Component<{
116119
]);
117120
};
118121

122+
animateDownloadFly.listen(() => {
123+
let fly: HTMLElement = cx.root.querySelector(".downloadfly")!;
124+
fly.addEventListener(
125+
"transitionend",
126+
() => {
127+
fly.style.opacity = "0";
128+
fly.classList.add("down");
129+
},
130+
{ once: true }
131+
);
132+
fly.style.opacity = "1";
133+
fly.classList.remove("down");
134+
});
135+
119136
const historyMenu = (e: MouseEvent) => {
120137
if (browser.activetab.history.states.length > 1) {
121138
createMenu(
@@ -171,6 +188,9 @@ export const Omnibox: Component<{
171188
}}
172189
icon={iconDownload}
173190
></IconButton>
191+
<div class="downloadfly down">
192+
<Icon icon={iconDownload}></Icon>
193+
</div>
174194
<CircularProgress
175195
progress={use(browser.downloadProgress)}
176196
></CircularProgress>
@@ -228,4 +248,37 @@ Omnibox.style = css`
228248
position: relative;
229249
gap: 0.2em;
230250
}
251+
252+
.downloadfly {
253+
position: absolute;
254+
top: 0;
255+
box-sizing: border-box;
256+
aspect-ratio: 1/1;
257+
align-items: center;
258+
justify-content: center;
259+
width: 100%;
260+
261+
display: flex;
262+
outline: none;
263+
border: none;
264+
font-size: 1.25em;
265+
background: none;
266+
color: var(--fg);
267+
border-radius: 0.2em;
268+
269+
transition: top 0.5s ease;
270+
}
271+
.downloadfly.down {
272+
top: 100vh;
273+
}
274+
.downloadfly::before {
275+
position: absolute;
276+
content: "";
277+
z-index: -1;
278+
height: 2em;
279+
width: 2em;
280+
border-radius: 50%;
281+
opacity: 0.5;
282+
background: var(--bg20);
283+
}
231284
`;

0 commit comments

Comments
 (0)