kute.js icon indicating copy to clipboard operation
kute.js copied to clipboard

The KUTE Execution Context (KEC) is not exported

Open rob-smallshire opened this issue 1 year ago • 1 comments

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
}

/ ...

rob-smallshire avatar Oct 08 '24 12:10 rob-smallshire