Comments (4)
If you're trying to alter a single style programmatically in Svelte 4, I'd recommend style directives.
<script lang="ts">
let scale = 1.0
function scale_up(){
scale = 1.5
}
function reset_scale(){
scale = 1.0
}
</script>
<img
style="width: 2em; height: 2em; background-color: red; display: inline-block; transition: scale 0.5s;"
style:scale
on:mouseover={scale_up}
on:mouseout={reset_scale}
alt="Parametrix logo"
/>
This also ties into the error you're seeing. In Svelte 4, the on:
syntax (note the colon) is used for element directives, including attaching callbacks to event listeners. In Svelte 5, you would use the onmouseover
attribute itself (without the colon).
from svelte.
Thank you James for your quick response!
I'd like avoiding using a variable because i want to clone those HTMLElement later on.
Here the code that will clone those slides : https://github.com/charlyoleg2/parametrix/blob/main/pkg/paramui/src/lib/Carousel.svelte
Here the result: https://charlyoleg2.github.io/parametrix/docs/prez
Click on one of the slides to start the presentation.
Because of the cloneNode(), I want to have all the HTML of a slide self-contained.
from svelte.
This might not be a great fit between what you're using (a lot of imperative DOM manipulation) and Svelte (a declarative framework by design).
I'm pretty sure you can do everything in that library with Svelte, and write it more expressively, with less code to type.
Have you already gone through the Svelte tutorial? A lot of the stuff can be achieved with bindings, actions, and declarative markup.
from svelte.
Using the event attribute and passing a string is highly discouraged. In Svelte 5, event attributes will error when being passed a string. As pointed out by others I suggest to solve this differently through the mechanics Svelte offers. Therefore closing as "wontfix"
from svelte.
Related Issues (20)
- Svelte 5: no warning/error on not-in-scope directive HOT 5
- $inspect destroying reactivity HOT 2
- Svelte 5: legacy mode wrong `export_let_unused` for `svelte:component` HOT 3
- `Component` type not working as expected HOT 1
- `@keyframes` in scoped style blocks do not work HOT 1
- `{@render children()}` crashes when importing WASM HOT 7
- Svelte 5: input bind:files has visually no two-way-binding HOT 5
- Ability to inject extra data to CSS class hashes to prevent CSS leaks HOT 5
- tag required in customElement options HOT 1
- Click on slot rendered content do not bubble events
- Imperatively controlling a component through $effect causes the effect to re-run indefinitely HOT 5
- [Svelte5] Unrelated state values are compiled into the same template effect when using class and the class:className directives. HOT 2
- Svelte 5 : `animate:flip` elements mispositioned after rapid state toggling HOT 1
- Svelte 5: reactivity inconsistent between state rune inside component and external HOT 2
- svelte.dev is not loading correctly in Nigeria unless VPN is used HOT 7
- `state_referenced_locally` warning appears on type guard
- Derived value is not reactive when used in an `else if` branch. HOT 17
- `migrate` fails on `$$Props` HOT 1
- "Unexpected token" parse error HOT 3
- Component not defined HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svelte.