Skip to content

Commit 05d7b34

Browse files
committed
Reduced default value for smoothButtonsTransitionMs
1 parent bcf3a0e commit 05d7b34

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

.changeset/tricky-shoes-sparkle.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@vkruglikov/react-telegram-web-app': patch
3+
---
4+
5+
- Reduced default value for `smoothButtonsTransitionMs`

docs/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ This object describe options be able to set through WebAppProvider
138138
| Name | Type | Description |
139139
| :--------------------------- | :-------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
140140
| `smoothButtonsTransition?` | `boolean` | When is `true`, we can smooth button transitions due to show(), hide() calls. So when you use MainButton or BackButton on multiple pages, there will be no noticeable flickering of the button during transitions **`Default Value`** `false` |
141-
| `smoothButtonsTransitionMs?` | `number` | **`Default Value`** `50` Why 50? https://w3c.github.io/requestidlecallback/#why50 **`Remarks`** |
141+
| `smoothButtonsTransitionMs?` | `number` | **`Default Value`** `10` **`Remarks`** |
142142

143143
---
144144

src/BackButton.tsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ const BackButton = ({ onClick }: BackButtonProps): null => {
2828
const WebApp = useWebApp();
2929
const BackButton = WebApp?.BackButton;
3030

31-
useSmoothButtonsTransition({
32-
show: BackButton?.show,
33-
hide: BackButton?.hide,
34-
currentShowedIdRef: system.BackButton,
35-
id: buttonId,
36-
});
37-
3831
useEffect(() => {
3932
if (!onClick || !BackButton) {
4033
return;
@@ -46,6 +39,13 @@ const BackButton = ({ onClick }: BackButtonProps): null => {
4639
};
4740
}, [onClick, BackButton]);
4841

42+
useSmoothButtonsTransition({
43+
show: BackButton?.show,
44+
hide: BackButton?.hide,
45+
currentShowedIdRef: system.BackButton,
46+
id: buttonId,
47+
});
48+
4949
return null;
5050
};
5151

src/core/context.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ export type Options = {
2020
*/
2121
smoothButtonsTransition?: boolean;
2222
/**
23-
* @defaultValue `50` Why 50? https://w3c.github.io/requestidlecallback/#why50
23+
* @defaultValue `10`
2424
* @remarks
2525
*/
2626
smoothButtonsTransitionMs?: number;
2727
};
2828

2929
export const DEFAULT_OPTIONS: Options = {
3030
smoothButtonsTransition: false,
31-
smoothButtonsTransitionMs: 50,
31+
smoothButtonsTransitionMs: 10,
3232
};
3333

3434
export const optionsContext = createContext<Options>(DEFAULT_OPTIONS);

0 commit comments

Comments
 (0)