滑动行为 负责 Telegram 迷你应用程序轻扫行为的💠组件。 检查支持要检查当前 Telegram 小应用程序版本是否支持轻扫行为,需要使用 isSupported 方法: Variable : - import { swipeBehavior } from '@telegram-apps/sdk';# ?9 n# n3 s+ u8 Z' C4 J3 ?
- 6 h2 }! J% r1 H4 x. X
- swipeBehavior.isSupported(); // boolean
复制代码Functions : - import { isSwipeBehaviorSupported } from '@telegram-apps/sdk';$ d) O) a( S) j4 |, F6 z3 ~1 ~
6 ?! a! W4 `2 u) {6 H5 i- isSwipeBehaviorSupported(); // boolean
复制代码 安装在使用该组件之前,有必要将其安装到正确配置的属性中。 为此,请使用 mount 方法。 它将更新 isMounted 信号属性。 Variable : - import { swipeBehavior } from '@telegram-apps/sdk';
3 [- I! ? `7 ~3 b0 u - , G' O: e8 |6 |, b9 S4 c, z
- swipeBehavior.mount();6 _. h1 D5 D8 h2 V+ k
- swipeBehavior.isMounted(); // true
复制代码Functions : - import {1 A" B; `) R( ~
- mountSwipeBehavior,
7 k: u5 T+ C& n% z9 Y0 C1 `- o R - isSwipeBehaviorMounted,3 L1 z$ a z: ~1 H
- } from '@telegram-apps/sdk';
* W5 a' y2 N, n - 7 O3 d0 @9 z( u0 b0 L% F8 @
- mountSwipeBehavior();
+ Q: P/ L- f$ Y. d! i/ K; l - isSwipeBehaviorMounted(); // true
复制代码要卸载,请使用 unmount 方法: Variable : - swipeBehavior.unmount();
5 P2 c7 T' |# X1 T - swipeBehavior.isMounted(); // false
复制代码Functions : - import {
; e/ V& n; W" p& c - unmountClosingBehavior,
4 h/ b( ?3 D1 B1 y6 G9 S2 H" X' o2 X - isSwipeBehaviorMounted,% j7 a. d$ ^! ^4 N7 p, W( p
- } from '@telegram-apps/sdk';8 D8 O6 I! o1 c+ V* {) D0 q( ]
- , K" u" W; a. y! b
- unmountSwipeBehavior(); $ ?7 v8 S. x$ B6 k& |. Z! v
- isSwipeBehaviorMounted(); // false
复制代码 控制纵向滑动要启用或禁用垂直轻扫,请使用 enableVertical 和 disableVertical 方法。 调用这些方法时,会更新 isVerticalEnabled 信号属性值。 Variable : - swipeBehavior.enableVertical();( m" |7 H) [6 @5 k; o
- swipeBehavior.isVerticalEnabled(); // true, W! N" H h( ?5 c6 c% e
# ^( D# y; `5 b( |2 s- swipeBehavior.disableVertical();& ?* h7 j$ |9 `) j' d6 }1 ?; n' Q
- swipeBehavior.isVerticalEnabled(); // false
复制代码Functions : - import {
. [& K* L4 w7 A) _ - enableVerticalSwipes,
1 u0 }' G3 D$ H. ]) Z9 u - disableVerticalSwipes," [2 k: L; F0 z" ^4 A D
- isVerticalSwipesEnabled,
8 A1 B: H" a, \+ l4 N - } from '@telegram-apps/sdk';* `/ ~5 \& j- a; U
) R( T- C- K) ]4 h- enableVerticalSwipes();, v$ T" k1 H) _- H1 h' b& i: y
- isVerticalSwipesEnabled(); // true
) S* y1 b$ K s - - `+ F7 b \: ^) a8 g" D
- disableVerticalSwipes();$ Y. f8 {' N- z) E1 u+ R3 O' s
- isVerticalSwipesEnabled(); // false
复制代码
. D" U" g3 u* f1 y
+ n5 B! Q6 r; j0 u2 G |