vantui-edit
Version:
一套适用于Taro3及React的vantui组件库
48 lines (41 loc) • 1.34 kB
JavaScript
import _typeof from "@babel/runtime/helpers/typeof";
import { style } from '../wxs/utils';
import { addUnit } from '../wxs/add-unit';
function isObj(x) {
var type = _typeof(x);
return x !== null && (type === 'object' || type === 'function');
}
function optionText(option, valueKey) {
return isObj(option) && option[valueKey] != null ? option[valueKey] : option;
}
function rootStyle(data) {
return style({
height: data.itemHeight * data.visibleItemCount + 'px'
});
}
function wrapperStyle(data) {
// if (process.env.TARO_ENV === 'h5') {
// const offset = addUnit(
// data.offset + (data.itemHeight * (data.visibleItemCount - 1)) / 2,
// )
// return style({
// transition: 'transform ' + data.duration + 'ms',
// 'line-height': addUnit(data.itemHeight),
// transform: 'translate3d(0, ' + offset + ', 0)',
// })
// }
var offset = data.offset + data.itemHeight * (data.visibleItemCount - 1) / 2;
return style({
transition: 'transform ' + data.duration + 'ms',
'line-height': data.itemHeight + 'px',
transform: 'translate3d(0, ' + offset + 'px' + ', 0)'
});
}
function styleTran(data) {
var res = {};
Object.keys(data).map(function (key) {
res[key] = addUnit(data[key]);
});
return style(res);
}
export { optionText, rootStyle, wrapperStyle, styleTran };