Skip to content

not possible to use own style with transition #8448

@dm-de

Description

@dm-de

Describe the bug

Transition generate own "style", which do not respect my style added to style-attribute.
style & transition style "collides" somehow and the transition breaks.

Reproduction

Resize window, so green sidebar is shown or hidden.

If you do this very quick (hide & show), you will see, that default size (200) is used instead of 400. This should not happen.

Remove style={style} in Side.svelte - and you will see, that it works like expected - but now, i am not able to set style this way (sidebar becomes default red).

So... if change happen slowly... style is merged correctly
if change happen quickly... style:width is not set.

App.svelte:

<script>
	import Side from './Side.svelte'
</script>

<Side size={400} style="background:#6c6;">
	content
</Side>

Side.svelte:

<script>
	import {fly} from 'svelte/transition'

	export let size = 200
	export let style = ''
	
	let trigger = 800
	let width = window.innerWidth
</script>

<svelte:window bind:innerWidth={width} />

{#if width >= trigger}
	<div
		style={style}
		style:width={size ? size + 'px' : undefined}
		transition:fly={{duration: 2000, x: -size}}
	>
		<slot/>
	</div>
{/if}

<style>
	div {
		position: absolute;
		top: 0;
		bottom: 0;
		left:0;
		width: 200px;
		background: #c66;
	}
</style>

Logs

No response

System Info

svelte 3.58.0
vite 4.1.3

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions