How to use the style-unit.convertUnit function in style-unit

To help you get started, we’ve selected a few style-unit 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 alibaba / rax / packages / driver-worker / src / Driver.js View on Github external
setStyles(node, styles) {
    let newStyles = node.style;

    for (let prop in styles) {
      let val = styles[prop];
      newStyles[prop] = convertUnit(val, prop);
    }
    // Assign to style for trigger style update
    node.style = newStyles;
  }
github alibaba / rax / packages / driver-weex / src / index.js View on Github external
setStyles(node, styles) {
    // TODO if more then one style update, call setStyles will be better performance
    for (let key in styles) {
      let val = styles[key];
      val = convertUnit(val, key);
      node.setStyle(key, val);
    }
  },
github alibaba / rax / packages / rax-set-native-props / src / index.js View on Github external
function setStyles(node, styles) {
  if (isWeb) {
    let tranformedStyles = {};
    for (let prop in styles) {
      let val = styles[prop];
      if (flexbox.isFlexProp(prop)) {
        flexbox[prop](val, tranformedStyles);
      } else {
        tranformedStyles[prop] = convertUnit(val, prop);
      }
    }
    for (let prop in tranformedStyles) {
      const transformValue = tranformedStyles[prop];
      // hack handle compatibility issue
      if (Array.isArray(transformValue)) {
        for (let i = 0; i < transformValue.length; i++) {
          node.style[prop] = transformValue[i];
        }
      } else {
        node.style[prop] = transformValue;
      }
    }
  } else if (isWeex) {
    shared.Host.driver.setStyle(node, styles);
  }
github alibaba / rax / packages / driver-worker / src / index.js View on Github external
setStyles(node, styles) {
      let tranformedStyles = {};

      for (let prop in styles) {
        let val = styles[prop];
        tranformedStyles[prop] = convertUnit(val, prop);
      }

      for (let prop in tranformedStyles) {
        const transformValue = tranformedStyles[prop];
        // hack handle compatibility issue
        if (Array.isArray(transformValue)) {
          for (let i = 0; i < transformValue.length; i++) {
            node.style[prop] = transformValue[i];
          }
        } else {
          node.style[prop] = transformValue;
        }
      }
      // For trigger attribute mutation
      node.style.cssText = styleToCSS(node.style);
    },
github alibaba / rax / universal / universal-transition / src / index.js View on Github external
export default function transition(node, styles, options, callback) {
  if (!node) return;

  if (typeof options == 'function' || options == null) {
    callback = options;
    options = {
      timingFunction: 'ease',
      duration: 0,
      delay: 0,
    };
  }

  for (let prop in styles) {
    styles[prop] = convertUnit(styles[prop], prop);
  }

  if (isWeex) {
    const animation = __weex_require__('@weex-module/animation');
    animation.transition(node.ref, {
      styles,
      timingFunction: options.timingFunction || 'linear',
      delay: options.delay || 0,
      duration: options.duration || 0,
      needLayout: options.needLayout || false
    }, callback || function() {});
  } else if (isWeb) {
    const properties = Object.keys(styles);
    const duration = options.duration || 0; // ms
    const timingFunction = options.timingFunction || 'linear';
    const delay = options.delay || 0; // ms
github alibaba / rax / packages / driver-weex / src / index.js View on Github external
createElement(component) {
    const htmlElement = w3cElements[component.type];
    if (htmlElement) {
      component = htmlElement.parse(component);
    }

    let props = component.props;
    let events = [];
    let style = {};
    let originStyle = props[STYLE];
    for (let prop in originStyle) {
      style[prop] = convertUnit(originStyle[prop], prop);
    }

    let node = document.createElement(component.type, {
      style,
    });

    this.setNativeProps(node, props, true);

    return node;
  },
github alibaba / rax / packages / driver-universal / src / weex.js View on Github external
createElement(type, props = {}) {
      const style = {};
      const originStyle = props.style;
      if (originStyle) {
        for (let prop in originStyle) {
          style[prop] = convertUnit(originStyle[prop], prop);
        }
      }
      return DriverWeex.createElement(type, Object.assign({}, props, { style }));
    },
    setStyle(node, style) {

style-unit

style-unit

BSD-3-Clause
Latest version published 2 years ago

Package Health Score

59 / 100
Full package analysis