Code Monkey home page Code Monkey logo

Comments (4)

jrmoynihan avatar jrmoynihan commented on September 28, 2024

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.

charlyoleg2 avatar charlyoleg2 commented on September 28, 2024

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.

jrmoynihan avatar jrmoynihan commented on September 28, 2024

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.

dummdidumm avatar dummdidumm commented on September 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.