Browse Source

Merge branch 'iteration-20240627-scroll' into ponline

lex 8 months ago
parent
commit
ea4629853c
2 changed files with 26 additions and 5 deletions
  1. 21 1
      src/components/col-sticky/index.module.less
  2. 5 4
      src/components/col-sticky/index.tsx

+ 21 - 1
src/components/col-sticky/index.module.less

@@ -1,7 +1,27 @@
 .white {
   background-color: #fff;
-  > div {
+
+  .pad {
     padding: 15px;
     box-shadow: 0px 0px 10px 0px rgba(216, 216, 216, 0.5);
   }
 }
+
+.sticky {
+  position: sticky;
+  top: 0;
+  z-index: 99;
+}
+
+// .white {
+//   background-color: #fff;
+
+//   >div {
+//     padding-top: 15px;
+//     box-shadow: 0px 0px 10px 0px rgba(216, 216, 216, 0.5);
+//   }
+// }
+
+.white-only {
+  background-color: #fff;
+}

+ 5 - 4
src/components/col-sticky/index.tsx

@@ -1,4 +1,3 @@
-import { useRect } from '@vant/use'
 import { PropType, defineComponent } from 'vue'
 import styles from './index.module.less'
 import { useResizeObserver } from '@vueuse/core'
@@ -64,12 +63,10 @@ export default defineComponent({
     } else {
       this.divStyle.bottom = this.offsetBottom || '0px'
     }
-
     try {
       useResizeObserver((this as any).$refs.div2, (entries: any) => {
         const entry = entries[0]
         const { height } = entry.contentRect
-        // console.log(height, 'height')
         if (Math.abs(height - this.heightV) > 1) {
           setTimeout(() => {
             this.__initHeight(height)
@@ -122,7 +119,11 @@ export default defineComponent({
           ]}
           style={[this.divStyle, this.sectionStyle]}
         >
-          <div ref="div2">{this.$slots.default && this.$slots.default()}</div>
+          <div ref="div2">
+            <div class={styles.pad}>
+              {this.$slots.default && this.$slots.default()}
+            </div>
+          </div>
         </div>
       </div>
     )