|
|
@@ -1,23 +1,10 @@
|
|
|
<template>
|
|
|
<view class="ruler-wrapper" v-show="visible">
|
|
|
- <scroll-view
|
|
|
- class="ruler-scroll"
|
|
|
- scroll-x
|
|
|
- :scroll-left="scrollLeft"
|
|
|
- :scroll-with-animation="useAnimation"
|
|
|
- @scroll="onScroll"
|
|
|
- @touchend="onTouchEnd"
|
|
|
- @touchcancel="onTouchEnd"
|
|
|
- scroll-into-view=""
|
|
|
- >
|
|
|
+ <scroll-view class="ruler-scroll" scroll-x :scroll-left="scrollLeft" :scroll-with-animation="useAnimation"
|
|
|
+ @scroll="onScroll" @touchend="onTouchEnd" @touchcancel="onTouchEnd" scroll-into-view="">
|
|
|
<view class="ruler-inner" :style="{ width: totalWidth + 'px' }">
|
|
|
- <view
|
|
|
- v-for="(g, idx) in gridList"
|
|
|
- :key="idx"
|
|
|
- class="grid-item"
|
|
|
- :class="{ long: g.isLongGrid }"
|
|
|
- :style="{ width: props.gutter + 'px', height: g.showText ? '40px' : '24px' }"
|
|
|
- >
|
|
|
+ <view v-for="(g, idx) in gridList" :key="idx" class="grid-item" :class="{ long: g.isLongGrid }"
|
|
|
+ :style="{ width: props.gutter + 'px', height: g.showText ? '40px' : '24px' }">
|
|
|
<text v-if="g.showText" class="grid-num">{{ g.displayNum }}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -129,11 +116,49 @@ function onTouchEnd() {
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
-.ruler-wrapper { position: relative; height: 80rpx; display:flex; align-items:center }
|
|
|
-.ruler-scroll { width: 100%; height: 80rpx }
|
|
|
-.ruler-inner { display:flex; align-items:flex-end }
|
|
|
-.grid-item { width: 10px; height: 24px; display:flex; align-items:flex-end; justify-content:center }
|
|
|
-.grid-item.long { height: 40px }
|
|
|
-.grid-num { font-size: 24rpx; color: #666 }
|
|
|
-.indicator { position: absolute; left: 50%; top: 0; transform: translateX(-50%); width: 2px; height: 100%; background: #ff6a00 }
|
|
|
+.ruler-wrapper {
|
|
|
+ position: relative;
|
|
|
+ height: 80rpx;
|
|
|
+ display: flex;
|
|
|
+ align-items: center
|
|
|
+}
|
|
|
+
|
|
|
+.ruler-scroll {
|
|
|
+ width: 100%;
|
|
|
+ height: 80rpx
|
|
|
+}
|
|
|
+
|
|
|
+.ruler-inner {
|
|
|
+ display: flex;
|
|
|
+ align-items: flex-end
|
|
|
+}
|
|
|
+
|
|
|
+.grid-item {
|
|
|
+ width: 10px;
|
|
|
+ height: 24px;
|
|
|
+ display: flex;
|
|
|
+ align-items: flex-end;
|
|
|
+ justify-content: center;
|
|
|
+ border-right: 1px solid #ccc
|
|
|
+}
|
|
|
+
|
|
|
+.grid-item.long {
|
|
|
+ height: 40px;
|
|
|
+ border-right: 2px solid #333
|
|
|
+}
|
|
|
+
|
|
|
+.grid-num {
|
|
|
+ font-size: 24rpx;
|
|
|
+ color: #666
|
|
|
+}
|
|
|
+
|
|
|
+.indicator {
|
|
|
+ position: absolute;
|
|
|
+ left: 50%;
|
|
|
+ top: 0;
|
|
|
+ transform: translateX(-50%);
|
|
|
+ width: 2px;
|
|
|
+ height: 100%;
|
|
|
+ background: #ff6a00
|
|
|
+}
|
|
|
</style>
|