thednp / kute.js

KUTE.js is a JavaScript animation engine for modern browsers.
http://thednp.github.io/kute.js
MIT License
2.59k stars 175 forks source link

The KUTE Execution Context (KEC) is not exported #125

Open rob-smallshire opened 2 days ago

rob-smallshire commented 2 days ago

I was not able to plug-in a new Component/Animation at run-time without building my own distribution because the Kute Execution Context (KEC) is not exported in the KUTE namespace. According to your own code and the example. onStart functions should register the property-updating function in the KEC, but for this to happen, the KEC needs to be available.

I worked around this by modifying your exported KUTE object to include KEC,

const KUTE = {
  Animation,
  Components,

  // Tween Interface
  Tween,
  fromTo,
  to,
  // Tween Collection
  TweenCollection,
  allFromTo,
  allTo,
  // Tween Interface

  Objects,
  Util,
  CubicBezier,
  Easing,
  Render,
  Interpolate: interpolate,
  Process,
  Internals: internals,
  Selector: selector,
  Version,
  KEC  // <<< ADDED.
};

export { KUTE as default };

and then qualified my references to KEC with KUTE in the definition of my onStart function for my component:

import KUTE from "./kute.mjs";

// ...

function onStartComponent(tweenProp, value) {
    if (!KUTE.KEC[tweenProp] && this.valuesEnd[tweenProp]) {
        KUTE.KEC[tweenProp] = (elem, a, b, v) => {
            const iParams = interpolateViewBox(a, b, v);
            elem.setAttribute('viewBox', joinViewBox(iParams));
        };
    }
}

const componentFunctions = {
    prepareStart: prepareComponentCurrentValue,
    prepareProperty: prepareComponentValue,
    onStart: onStartComponent
}

/ ...
thednp commented 1 day ago

I haven't had the time to check on KUTE.js in the last couple of months, last time I was, it was a beginning of a Typescript rework, which had an unfortunate ending caused by loss of data. The KEC is attached to the Window object by one of the core functions, but I wonder, are you trying to integrate with some SSR framework?

I'm thinking of a full rework to easily integrate any framework and/or headless systems. I'm open to any suggestion!! Thanks :heart: