Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
}
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);
}
},
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);
}
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);
},
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
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;
},
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) {