Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

AP-1075 Fix spinner remounting restarts #137

Merged
merged 2 commits into from
Nov 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Loaders/LoadingSpinner.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @jsx jsx */
import React from "react";
import * as CSS from "csstype";
import isChromatic from "storybook-chromatic/isChromatic";
import { jsx, keyframes } from "@emotion/core";
import { colors } from "../colors";

Expand Down Expand Up @@ -73,6 +74,9 @@ export const LoadingSpinner: React.FC<Props> = ({

const pixelSize = SIZE_MAP[size];

const mountTime = React.useRef(Date.now());
const mountDelay = isChromatic() ? 0 : -(mountTime.current % 540);

return (
<svg
className={className}
Expand All @@ -97,6 +101,7 @@ export const LoadingSpinner: React.FC<Props> = ({
css={{
animation: `${SPIN} 540ms linear infinite`,
willChange: "transform",
animationDelay: `${mountDelay}ms`,
}}
fill={asteroidColor}
r="10"
Expand Down
4 changes: 4 additions & 0 deletions typings/storybook-chromatic__isChromatic/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module "storybook-chromatic/isChromatic" {
const isChromatic: () => boolean;
export default isChromatic;
}