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
{{ message }}
Repository navigation
Commit fb0b44c
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: src/content/reference/react/Activity.md
+39-17Lines changed: 39 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -339,13 +339,13 @@ b {
339
339
340
340
</Sandpack>
341
341
342
-
Activity also preserves other browser-managed state, such as scroll position and media playback position. The following examples use the same video player to compare removing and hiding a `<video>` element. Play the video, hide it, show it again, and then select **Play**.
342
+
Activity also preserves other browser-managed state, such as scroll position and media playback position. The following examples use the same video player to compare removing and hiding a `<video>` element. Play the video, switch to the Home tab, return to the Video tab, and then select **Play**.
343
343
344
344
<RecipestitleText="The difference between removing and hiding a video"titleId="examples-preserving-media-state">
345
345
346
346
#### Removing the video resets its playback position {/*removing-the-video-resets-its-playback-position*/}
347
347
348
-
This version conditionally renders the video player. Hiding it removes the `<video>` element from the DOM, so playback starts from the beginning when you show it again.
348
+
This version conditionally renders the active tab. Switching to Home removes the `<video>` element from the DOM, so playback starts from the beginning when you return to Video.
349
349
350
350
<Sandpack>
351
351
@@ -354,14 +354,24 @@ import { useState } from 'react';
{activeTab ==='home'&&<p>Welcome to my profile!</p>}
374
+
{activeTab ==='video'&&<VideoPlayer />}
365
375
</>
366
376
);
367
377
}
@@ -394,12 +404,12 @@ export default function VideoPlayer() {
394
404
```
395
405
396
406
```css
407
+
button {
408
+
margin-right: 10px;
409
+
}
397
410
.video-player {
398
411
margin-top: 10px;
399
412
}
400
-
.video-playerbutton {
401
-
margin-right: 10px;
402
-
}
403
413
.video-playervideo {
404
414
display: block;
405
415
margin-top: 10px;
@@ -412,7 +422,7 @@ export default function VideoPlayer() {
412
422
413
423
#### Hiding the video preserves its playback position {/*hiding-the-video-preserves-its-playback-position*/}
414
424
415
-
This version renders the video player inside an Activity boundary. Hiding it preserves the `<video>` element, so playback continues from the same position when you show it and select **Play** again.
425
+
This version renders both tabs inside Activity boundaries. Switching to Home hides the `<video>` element without removing it, so playback continues from the same position when you return to Video and select **Play** again.
0 commit comments