How to use the shifty.tween function in shifty

To help you get started, we’ve selected a few shifty examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github noobaa / noobaa-core / frontend / src / app / extenders / tween.js View on Github external
export default function tweenExtender(
    target,
    {
        duration = 1000,
        easing = 'easeOutQuad',
        resetValue = target(),
        resetOnChange = false,
        useDiscreteValues = false
    }
) {
    const result  = ko.observable(resetValue);
    tween({
        from: { val: resetValue },
        to: { val: target() },
        duration: duration,
        easing: easing,
        step: ({ val }) => result(val)
    });

    // Create a pure observable to control the life time of the subscription
    // and to allow for automatic disposing in order to prevent memory leaks.
    const pure = ko.pureComputed(
        useDiscreteValues ? () => Math.round(result()) : result
    );

    let subscription;
    pure.subscribe(() => {
        subscription = target.subscribe(val =>
github AugurProject / augur-ui / src / modules / app / components / app / app.jsx View on Github external
[menuKey]: {
          ...this.state[menuKey],
          ...newState
        }
      });
    };
    const { updateIsAnimating } = this.props;
    const alreadyDone =
      (!nowOpen && this.state[menuKey].scalar === 0) ||
      (nowOpen && this.state[menuKey].scalar === 1);
    if (alreadyDone) {
      if (cb && typeof cb === "function") cb();
      updateIsAnimating(false);
    } else {
      const baseMenuState = { open: nowOpen };
      const currentTween = tween({
        from: { value: this.state[menuKey].scalar },
        to: { value: nowOpen ? 1 : 0 },
        duration: 500,
        easing: "easeOutQuad",
        step: newState => {
          setMenuState(
            Object.assign({}, baseMenuState, { scalar: newState.value })
          );
        }
      }).then(() => {
        updateIsAnimating(false);
        if (cb && typeof cb === "function") cb();
        setMenuState({ locked: false, currentTween: null });
      });
      updateIsAnimating(true);
      setMenuState({ currentTween });
github noobaa / noobaa-core / frontend / src / app / components / bucket / bucket-summary / bar.js View on Github external
onState(height, animate) {
        const lastHeight = this.height() || 0;

        if (animate) {
            tween({
                duration: 1000,
                delay: 350,
                easing: 'easeOutQuad',
                step: this.onStep,
                from: { val: lastHeight },
                to: { val: height }
            });
        } else {
            this.height(height);
        }
    }
github noobaa / noobaa-core / frontend / src / app / components / modals / upgrading-system-modal / upgrading-system-modal.js View on Github external
function _startFakeProgress(stepCallback) {
    return tween({
        from: { val: 0 },
        to: { val: .95 },
        delay: 1000,
        duration: 4 * 60 * 1000,
        easing: 'linear',
        step: ({ val }) => stepCallback(val)
    });
}
github streetmix / streetmix / assets / scripts / util / helpers.js View on Github external
export function animate (el, props, duration) {
  const initialProps = {}

  Object.keys(props).forEach(function (prop) {
    initialProps[prop] = el[prop] || 0
  })

  tween({
    from: initialProps,
    to: props,
    duration: duration,
    step: (state) => Object.assign(el, state)
  })
}
github AugurProject / augur / src / modules / categories / components / categories-view / categories-view.jsx View on Github external
const doCarouselTween = (from, to, cb) =>
      tween({
        from: { value: from },
        to: { value: to },
        duration: 500,
        easing: "easeOutQuad",
        step: stepObj => {
          if (this.componentWrapper)
            this.setState({ heroCategoryOpacity: stepObj.value });
        }
      }).then(cb);

shifty

The fastest JavaScript animation engine on the web

MIT
Latest version published 1 year ago

Package Health Score

64 / 100
Full package analysis