Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🤔怎么禁止列头文字跟随滚动条移动 #2347

Closed
4 tasks
li-guanlong opened this issue Sep 12, 2023 · 2 comments
Closed
4 tasks

🤔怎么禁止列头文字跟随滚动条移动 #2347

li-guanlong opened this issue Sep 12, 2023 · 2 comments
Labels
❔question 疑问/使用问题

Comments

@li-guanlong
Copy link

🏷 Version

Package Version
@antv/s2
@antv/s2-react
@antv/s2-vue

Sheet Type

  • PivotSheet
  • [✔️ ] TableSheet
  • GridAnalysisSheet
  • StrategySheet
  • EditableSheet

🖋 Description

怎么禁止列头文字跟随滚动条移动
image

🔗 Reproduce Link

😊 Expected Behavior

😅 Current Behavior

@li-guanlong li-guanlong added the ❔question 疑问/使用问题 label Sep 12, 2023
@lijinke666
Copy link
Member

ref: #2223

@lijinke666
Copy link
Member

文字滚动吸附是 S2 的一个特性, 可以自定义 ColCell, 复写 getTextPosition 自定义文字的 x 坐标

if (isLeaf) {
return getTextAndFollowingIconPosition(
contentBox,
textStyle,
this.actualTextWidth,
iconStyle,
this.getActionIconsCount(),
).text;
}

import { ColCell, getTextAndFollowingIconPosition } from '@antv/s2'

class CustomColCell extends ColCell {
  getTextPosition() {
    const defaultTextPosition = super.getTextPosition();
    const textStyle = this.getTextStyle();
    const contentBox = this.getContentArea();
    const iconStyle = this.getIconStyle();

    const { text } = getTextAndFollowingIconPosition(
      contentBox,
      textStyle,
      this.actualTextWidth,
      iconStyle,
      this.getActionIconsCount(),
    );

    return {
      ...defaultTextPosition,
      x: text.x,
    };
  }
}


const s2Options = {
  colCell: (...args) => new CustomColCell(...args),
}

Kapture 2023-10-12 at 11 48 19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❔question 疑问/使用问题
Projects
None yet
Development

No branches or pull requests

2 participants