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

[comp: affix] add affix component #138

Closed
1 task done
jackson-yyy opened this issue Jan 14, 2021 · 8 comments · Fixed by #209
Closed
1 task done

[comp: affix] add affix component #138

jackson-yyy opened this issue Jan 14, 2021 · 8 comments · Fixed by #209
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@jackson-yyy
Copy link
Contributor

jackson-yyy commented Jan 14, 2021

  • I have searched the issues of this repository and believe that this is not a duplicate.

What problem does this feature solve?

affix

What does the proposed API look like?

props

名称 说明 类型 默认值
offset 距离窗口顶部的偏移量,到达时会触发fix
number | { top:number. bottom:number, left:number, right:number} -
container 用于定位的容器,会监听容器的滚动事件,用函数返回 () => HTMLElement | window () => window
throttleTime 节流时间(ms)设置,用于提高性能
开启后affix位置更新会产生延迟
number -

event

名称 说明 回调参数
status-changed 固定/非固定状态切换时的事件 boolean

slot

名称 说明
default 默认插槽
@jackson-yyy jackson-yyy added the enhancement New feature or request label Jan 14, 2021
@danranVm danranVm changed the title [comp: ] add affix component [comp: affix] add affix component Jan 14, 2021
@danranVm danranVm added this to the v1.0.0 milestone Jan 14, 2021
@danranVm danranVm mentioned this issue Jan 14, 2021
95 tasks
@jackson-yyy
Copy link
Contributor Author

@danranVm 麻烦看下api这样设计是否合理:bowtie:

@danranVm
Copy link
Member

  • offset 的 4 个 API 有点臃肿
    • 建议保留两个 offsetTop, offsetBottom(参考自 antd)
    • 或者 4 个合并成 1 个, offset: number | { top:number. bottom:number, left:number, right:number}, 为 number 时,默认为 top
  • container 我看 antd 是一个函数,不知道他们为什么这么设计,你考虑下。
  • useAbsolute 这个不需要吧,用户自己用样式去控制就好了。

@jackson-yyy
Copy link
Contributor Author

jackson-yyy commented Jan 19, 2021

  • offset 的 4 个 API 有点臃肿

    • 建议保留两个 offsetTop, offsetBottom(参考自 antd)
    • 或者 4 个合并成 1 个, offset: number | { top:number. bottom:number, left:number, right:number}, 为 number 时,默认为 top
  • container 我看 antd 是一个函数,不知道他们为什么这么设计,你考虑下。

  • useAbsolute 这个不需要吧,用户自己用样式去控制就好了。

@danranVm
感谢提出的建议

第一点建议采纳
第二点我也在思考container 为啥用函数返回,我再研究下
第三点,加入useAbsolute是参考了fusion design的做法,用以解决ant-design中,target容器不为window时,元素会跑到容器外的问题,开启后计算position的方式会改变

参考
fusion design https://fusion.design/pc/component/basic/affix
ant-degsign的issue https://www.antdv.com/components/affix-cn/#FAQ

@danranVm
Copy link
Member

@jackson-yyy OK, 那我没什么问题了。

@ssccchh
Copy link

ssccchh commented Jan 22, 2021

修改后的api问题不大,实现的时候注意一下内存和性能问题

@jackson-yyy
Copy link
Contributor Author

不知这样设计是否合理:
取消useAbsolute属性,内部判断container,如果是window就采用fix定位,否则采用absolute定位,最后达到基于container进行affix的效果,也能减少prop的数量
@danranVm @Pupils-web

@danranVm
Copy link
Member

不知这样设计是否合理:
取消useAbsolute属性,内部判断container,如果是window就采用fix定位,否则采用absolute定位,最后达到基于container进行affix的效果,也能减少prop的数量
@danranVm @Pupils-web

恩,这样更好点。

@jackson-yyy
Copy link
Contributor Author

不知这样设计是否合理:
取消useAbsolute属性,内部判断container,如果是window就采用fix定位,否则采用absolute定位,最后达到基于container进行affix的效果,也能减少prop的数量
@danranVm @Pupils-web

恩,这样更好点。

ok,那我按照这样设计了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants