index.wxs 868 B

123456789101112131415161718192021222324252627282930313233343536
  1. /* eslint-disable */
  2. var style = require('../wxs/style.wxs');
  3. var addUnit = require('../wxs/add-unit.wxs');
  4. function isObj(x) {
  5. var type = typeof x;
  6. return x !== null && (type === 'object' || type === 'function');
  7. }
  8. function optionText(option, valueKey) {
  9. return isObj(option) && option[valueKey] != null ? option[valueKey] : option;
  10. }
  11. function rootStyle(data) {
  12. return style({
  13. height: addUnit(data.itemHeight * data.visibleItemCount),
  14. });
  15. }
  16. function wrapperStyle(data) {
  17. var offset = addUnit(
  18. data.offset + (data.itemHeight * (data.visibleItemCount - 1)) / 2
  19. );
  20. return style({
  21. transition: 'transform ' + data.duration + 'ms',
  22. 'line-height': addUnit(data.itemHeight),
  23. transform: 'translate3d(0, ' + offset + ', 0)',
  24. });
  25. }
  26. module.exports = {
  27. optionText: optionText,
  28. rootStyle: rootStyle,
  29. wrapperStyle: wrapperStyle,
  30. };