You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sets `spring.target` to `value` and returns a `Promise` that resolves if and when `spring.current` catches up to it.
76
+
77
+
If `options.instant` is `true`, `spring.current` immediately matches `spring.target`.
78
+
79
+
If `options.preserveMomentum` is provided, the spring will continue on its current trajectory for
80
+
the specified number of milliseconds. This is useful for things like 'fling' gestures.
81
+
82
+
</div>
83
+
</div>
84
+
85
+
<divclass="ts-block-property">
86
+
87
+
```dts
88
+
damping: number;
89
+
```
90
+
91
+
<divclass="ts-block-property-details"></div>
92
+
</div>
93
+
94
+
<divclass="ts-block-property">
95
+
96
+
```dts
97
+
precision: number;
98
+
```
99
+
100
+
<divclass="ts-block-property-details"></div>
101
+
</div>
102
+
103
+
<divclass="ts-block-property">
104
+
105
+
```dts
106
+
stiffness: number;
107
+
```
108
+
109
+
<divclass="ts-block-property-details"></div>
110
+
</div>
111
+
112
+
<divclass="ts-block-property">
113
+
114
+
```dts
115
+
target: T;
116
+
```
117
+
118
+
<divclass="ts-block-property-details">
119
+
120
+
The end value of the spring.
121
+
This property only exists on the `Spring` class, not the legacy `spring` store.
122
+
123
+
</div>
124
+
</div>
125
+
126
+
<divclass="ts-block-property">
127
+
128
+
```dts
129
+
get current(): T;
130
+
```
131
+
132
+
<divclass="ts-block-property-details">
133
+
134
+
The current value of the spring.
135
+
This property only exists on the `Spring` class, not the legacy `spring` store.
136
+
137
+
</div>
138
+
</div></div>
139
+
140
+
141
+
142
+
## Tween
13
143
14
144
<blockquoteclass="since note">
15
145
16
-
Available since 5.7.0
146
+
Available since 5.8.0
17
147
18
148
</blockquote>
19
149
20
-
A [media query](/docs/svelte/svelte-reactivity#MediaQuery) that matches if the user [prefers reduced motion](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion).
150
+
A wrapper for a value that tweens smoothly to its target value. Changes to `tween.target` will cause `tween.current` to
151
+
move towards it over time, taking account of the `delay`, `duration` and `easing` options.
21
152
22
153
```svelte
23
154
<script>
24
-
import { prefersReducedMotion } from 'svelte/motion';
Sets `tween.target` to `value` and returns a `Promise` that resolves if and when `tween.current` catches up to it.
212
+
213
+
If `options` are provided, they will override the tween's defaults.
214
+
215
+
</div>
216
+
</div>
217
+
218
+
<divclass="ts-block-property">
219
+
220
+
```dts
221
+
get current(): T;
222
+
```
223
+
224
+
<divclass="ts-block-property-details"></div>
225
+
</div>
226
+
227
+
<divclass="ts-block-property">
228
+
229
+
```dts
230
+
set target(v: T);
45
231
```
46
232
233
+
<divclass="ts-block-property-details"></div>
47
234
</div>
48
235
236
+
<divclass="ts-block-property">
237
+
238
+
```dts
239
+
get target(): T;
240
+
```
241
+
242
+
<divclass="ts-block-property-details"></div>
243
+
</div>
244
+
245
+
<divclass="ts-block-property">
246
+
247
+
```dts
248
+
#private;
249
+
```
250
+
251
+
<divclass="ts-block-property-details"></div>
252
+
</div></div>
253
+
49
254
50
255
51
256
## spring
52
257
258
+
<blockquoteclass="tag deprecated note">
259
+
260
+
Use [`Spring`](/docs/svelte/svelte-motion#Spring) instead
261
+
262
+
</blockquote>
263
+
53
264
The spring function in Svelte creates a store whose value is animated, with a motion that simulates the behavior of a spring. This means when the value changes, instead of transitioning at a steady rate, it "bounces" like a spring would, depending on the physics parameters provided. This adds a level of realism to the transitions and can enhance the user experience.
54
265
55
266
<divclass="ts-block">
@@ -67,6 +278,12 @@ function spring<T = any>(
67
278
68
279
## tweened
69
280
281
+
<blockquoteclass="tag deprecated note">
282
+
283
+
Use [`Tween`](/docs/svelte/svelte-motion#Tween) instead
284
+
285
+
</blockquote>
286
+
70
287
A tweened store in Svelte is a special type of store that provides smooth transitions between state values over time.
0 commit comments