scenejs icon indicating copy to clipboard operation
scenejs copied to clipboard

Is svelte-scenejs on the roadmap?

Open stemcc opened this issue 2 years ago • 3 comments

I've been enjoying working your svelte-movable library. Would love to know if you've considered a svelte client for scenejs.

stemcc avatar Aug 10 '22 23:08 stemcc

@stemcc

I will remake scenejs for all frameworks including svelte. (in hooks or reactive form)

I will release it within this month.

  • Concept
<script>
import { useSceneItem } from "scenejs";


const {
    left, top, transform,
    play,
} = useSceneItem({
   0: {
       left: "0px",
       top: "100px",
       transform: "translate(0px)",
   },
   1: {
       left: "100px",
       top: "100px",
       transform: "translate(100px)",
   },
});


play();
</script>
<div style={{ transform: $transform, left: $left, top: $top }}>
Target
</div>

daybrush avatar Aug 11 '22 00:08 daybrush

That's great to hear! Looking forward to it :-)

stemcc avatar Aug 11 '22 22:08 stemcc

@stemcc

[email protected] is released.

https://github.com/daybrush/scenejs/tree/master/packages/svelte-scenejs

$ npm install svelte-scenejs
<script>
import {
    useScene,
    useSceneItem,
    useFrame,
    useNowFrame,
} from "svelte-scenejs";


const scene = new Scene({
    "a1": {
        0: {
            left: "0px",
            top: "0px",
            transform: `translate(0px, 0px)`,
        },
        1: {
            left: "100px",
            top: "100px",
            transform: `translate(100px, 0px)`,
        },
    },
    "a2": {
        0: {
            left: "0px",
            top: "0px",
            transform: `translate(0px, 0px)`,
        },
        1: {
            left: "100px",
            top: "100px",
            transform: `translate(100px, 0px)`,
        },
    }
});
const { cssText: cssText1 } = useNowFrame(scene.getItem("a1"));
const { cssText: cssText2 } = useNowFrame(scene.getItem("a2"));

</script>
<div class="container">
    <div class="a1" style={$cssText1}></div>
    <div class="a2" style={$cssText2}></div>
</div>

There are still many shortcomings and explanations are insufficient.

  1. Tell me if there is something missing or a feature you want.
  2. Or suggest me if there is a better way.

daybrush avatar Dec 15 '22 20:12 daybrush