Sanakey
2021-01-31 53cc6f817625897935fb10c3845ad7be400f3036
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* eslint-disable */
var style = require('../wxs/style.wxs');
var addUnit = require('../wxs/add-unit.wxs');
 
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: addUnit(data.itemHeight * data.visibleItemCount),
  });
}
 
function wrapperStyle(data) {
  var 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)',
  });
}
 
module.exports = {
  optionText: optionText,
  rootStyle: rootStyle,
  wrapperStyle: wrapperStyle,
};