diff --git a/components/adams-predictor-method.tsx b/components/adams-predictor-method.tsx index 2a42145..9e2e330 100644 --- a/components/adams-predictor-method.tsx +++ b/components/adams-predictor-method.tsx @@ -1,6 +1,7 @@ 'use client'; import { useMemo, useState } from 'react'; +import { useScrollToResult } from '@/components/ui/use-scroll-to-result'; import katex from 'katex'; import { BookOpen, ChevronDown, Copy, Check } from 'lucide-react'; import { useI18n } from '@/components/i18n-provider'; @@ -110,6 +111,8 @@ export function AdamsPredictorMethod() { ? [...rows.slice(0, 4), null, ...rows.slice(-2)] : rows; + const resultRef = useScrollToResult(calculation); + return (
@@ -122,29 +125,31 @@ export function AdamsPredictorMethod() { conditionSub={t('adams.condition')} /> -
- - - setInputs((current) => ({ ...current, [key]: value }))} - onSubmit={(event) => { - event.preventDefault(); - setCalculationInputs({ ...inputs }); - }} - calculateLabel={t('adams.calculate')} - error={calculation.error} - /> -
-

- {t('adams.formula_title')} -

-
-

{t('adams.startup_note')}

-
- +
+
+ + + setInputs((current) => ({ ...current, [key]: value }))} + onSubmit={(event) => { + event.preventDefault(); + setCalculationInputs({ ...inputs }); + }} + calculateLabel={t('adams.calculate')} + error={calculation.error} + /> +
+

+ {t('adams.formula_title')} +

+
+

{t('adams.startup_note')}

+
+ +
-
+
{last && ( diff --git a/components/bisection-method.tsx b/components/bisection-method.tsx index 48d8191..286ac65 100644 --- a/components/bisection-method.tsx +++ b/components/bisection-method.tsx @@ -1,6 +1,7 @@ 'use client'; import { useMemo, useState } from 'react'; +import { useScrollToResult } from '@/components/ui/use-scroll-to-result'; import katex from 'katex'; import 'katex/dist/katex.min.css'; import { ArrowUpRight, Check, Info, Waves } from 'lucide-react'; @@ -44,6 +45,8 @@ export function BisectionMethod() { const renderKatex = (value: string) => katex.renderToString(value, { throwOnError: false }); const sign = (v: number) => (v < 0 ? 'text-neg' : 'text-pos'); + const resultRef = useScrollToResult(result); + return (
@@ -69,112 +72,114 @@ export function BisectionMethod() {
{/* INPUT */} - - - - }> -

{t('bisection.label_fn').split(' ')[0]} — {t('bisection.note_fn')} x^3 + x - 1

-
+
+ + - + }> +

{t('bisection.label_fn').split(' ')[0]} — {t('bisection.note_fn')} x^3 + x - 1

+
-
- {formula ? ( - - ) : ( - - {t('bisection.err_fn')} - - )} -
- -
-
- ε}> -

{t('bisection.label_eps')} — {t('bisection.note_eps').split(' — ')[1]}

-
+ - - - - -
- {t('bisection.sample_formula')} -
- {['sin(x)', 'cos(x)', 'sqrt(x)', 'log(x)', 'x^2', 'e^x'].map((t) => ( - - ))} +
+ {t('bisection.sample_formula')} +
+ {['sin(x)', 'cos(x)', 'sqrt(x)', 'log(x)', 'x^2', 'e^x'].map((t) => ( + + ))} +
-
- + +
{/* OUTPUT */} -
+
{result && ( x ≈ ${format(result.root, 8)} (${result.iterations} iteratsiyada)`} diff --git a/components/bvp-finite-difference-method.tsx b/components/bvp-finite-difference-method.tsx index d11ab22..03ddcff 100644 --- a/components/bvp-finite-difference-method.tsx +++ b/components/bvp-finite-difference-method.tsx @@ -1,6 +1,7 @@ 'use client'; import { useMemo, useState, type FormEvent } from 'react'; +import { useScrollToResult } from '@/components/ui/use-scroll-to-result'; import { Activity, Calculator, Check, Copy, Info } from 'lucide-react'; import katex from 'katex'; import { useI18n } from '@/components/i18n-provider'; @@ -121,6 +122,7 @@ export function BvpFiniteDifferenceMethod() { const [input, setInput] = useState(INITIAL); const [problemFields, setProblemFields] = useState(EMPTY_PROBLEM); const [result, setResult] = useState(null); + const resultRef = useScrollToResult(result); const [error, setError] = useState(''); const [parsedNotice, setParsedNotice] = useState(''); const [copiedNotebook, setCopiedNotebook] = useState(false); @@ -243,7 +245,7 @@ export function BvpFiniteDifferenceMethod() { { n: '03', t: t('bvp.map_3'), s: t('bvp.map_3_desc') }, ]} />
-