fix: stop currentTime binding updates during outros

svelte0/svelte-15053-fix-stop-currenttime-binding-updates-during-outros
svelte-triage-bot[bot] 4 weeks ago committed by GitHub
parent 221dcae8ca
commit b2a6c0c9f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,4 +1,7 @@
/** @import { Effect } from '#client' */
import { INERT } from '#client/constants';
import { render_effect, effect, teardown } from '../../../reactivity/effects.js';
import { active_effect } from '../../../runtime.js';
import { listen } from './shared.js';
/** @param {TimeRanges} ranges */
@ -19,6 +22,8 @@ function time_ranges_to_array(ranges) {
* @returns {void}
*/
export function bind_current_time(media, get, set = get) {
var effect = /** @type {Effect} */ (active_effect);
/** @type {number} */
var raf_id;
/** @type {number} */
@ -34,6 +39,8 @@ export function bind_current_time(media, get, set = get) {
raf_id = requestAnimationFrame(callback);
}
if ((effect.f & INERT) !== 0) return;
var next_value = media.currentTime;
if (value !== next_value) {
set((value = next_value));

@ -0,0 +1,13 @@
import { flushSync } from '../../../../src/index-client.js';
import { test } from '../../test';
export default test({
test({ target }) {
const button = /** @type {HTMLButtonElement} */ (target.querySelector('button'));
const audio = /** @type {HTMLAudioElement} */ (target.querySelector('audio'));
flushSync(() => button.click());
audio.currentTime = 1;
audio.dispatchEvent(new Event('timeupdate'));
}
});

@ -0,0 +1,11 @@
<script>
import { fade } from 'svelte/transition';
let item = $state({ currentTime: 0 });
</script>
<button onclick={() => (item = null)}>remove</button>
{#if item}
<audio bind:currentTime={item.currentTime} transition:fade={{ duration: 100 }}></audio>
{/if}
Loading…
Cancel
Save