Skip to content

Commit

Permalink
fix(material): avoid random animation
Browse files Browse the repository at this point in the history
Closes #290
  • Loading branch information
juanrgm committed Jul 16, 2024
1 parent 55b070c commit 39bbc21
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions packages/material/src/LinearProgress/LinearProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ import { redefine } from "@suid/system/createStyled";
import { InPropsOf } from "@suid/types";
import randomString from "@suid/utils/randomString";
import clsx from "clsx";
import { createEffect, createSignal, JSX, Show } from "solid-js";
import {
createEffect,
createRenderEffect,
createSignal,
JSX,
Show,
} from "solid-js";

const $ = createComponentFactory<LinearProgressTypeMap>()({
name: "MuiLinearProgress",
Expand Down Expand Up @@ -302,11 +308,6 @@ const LinearProgress = $.component(function LinearProgress({
element.ref.ariaValueNow = Math.round(props.value).toString();
element.ref.ariaValueMin = "0";
element.ref.ariaValueMax = "100";
let transform = props.value - 100;
if (theme.direction === "rtl") {
transform = -transform;
}
setBar1Style({ transform: `translateX(${transform}%)` });
} else if (process.env.NODE_ENV !== "production") {
console.error(
"MUI: You need to provide a value prop " +
Expand All @@ -316,6 +317,18 @@ const LinearProgress = $.component(function LinearProgress({
}
});

createRenderEffect(() => {
if (props.variant === "determinate" || props.variant === "buffer") {
if (props.value !== undefined) {
let transform = props.value - 100;
if (theme.direction === "rtl") {
transform = -transform;
}
setBar1Style({ transform: `translateX(${transform}%)` });
}
}
});

createEffect(() => {
if (props.variant === "buffer") {
if (props.valueBuffer !== undefined) {
Expand Down

0 comments on commit 39bbc21

Please sign in to comment.