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: anchor] add anchor component #93

Closed
1 task done
bunnybunny3 opened this issue Dec 31, 2020 · 6 comments
Closed
1 task done

[comp: anchor] add anchor component #93

bunnybunny3 opened this issue Dec 31, 2020 · 6 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@bunnybunny3
Copy link
Contributor

bunnybunny3 commented Dec 31, 2020

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

What problem does this feature solve?

用于跳转到页面指定位置。

What does the proposed API look like?

  • 可设置是否是固定模式。即是否将其固定在可视范围
  • 可设置固定模式下是否显示小圆点
  • 可指定滚动容器,默认window
  • 可设置距离窗口顶部达到指定偏移量(offsetTop)后触发其高亮
  • 可设置锚点滚动偏移量,默认同offsetTop

例子

<ix-anchor>
    <ix-link href="#example" title="example" />
    <ix-link href="#api" title="api">
      <ix-link href="#props" title="props" />
      <ix-link href="#emit" title="emit" />
    </ix-link>
 </ix-anchor>

API

ix-anchor

Props

名称 说明 类型 默认值 全局配置 备注
affix 是否是固定模式 boolean true - -
showInkInFixed 固定模式是否显示小圆点 boolean false -
target 指定滚动的容器 string|HTMLElement window - -
offsetTop 距离窗口顶部达到指定偏移量后触发激活 number - - -
targetOffset 锚点滚动偏移量,默认与 offsetTop 相同 number - - -

Emits

名称 说明 参数
click 锚点元素点击事件 e: Event, link: Object
change 监听锚点链接改变 activeLink: string

ix-link

Props

除以下表格外还支持原生 a 元素的所有属性

名称 说明 类型 默认值 全局配置 备注
href 锚点链接 string - - -
title 文字内容 string - - -
@bunnybunny3 bunnybunny3 added the enhancement New feature or request label Dec 31, 2020
@danranVm danranVm mentioned this issue Dec 31, 2020
95 tasks
@danranVm
Copy link
Member

danranVm commented Dec 31, 2020

@Pupils-web @danranVm 负责此组件的 review, API 设计完成后请 @ 他们

@danranVm danranVm added this to the v1.0.0 milestone Dec 31, 2020
@bunnybunny3
Copy link
Contributor Author

@danranVm @Pupils-web 麻烦review 下 api

@danranVm
Copy link
Member

danranVm commented Feb 26, 2021

  • ix-anchor
    • container 改成 target 吧,和 BackTop 和 Affix 组件保持一致,你也可以参考一下这两个组件的代码,有封装好的工具函数
  • ix-anchor-link 改成 ix-link 吧
    • 然后实现可以用 a 元素实现
    • 文档中不需要写 target ,只要声明一句(参考 Button 组件):除以下表格之外还支持原生 a 元素的所有属性

@ssccchh
Copy link

ssccchh commented Feb 26, 2021

我没有问题

@bunnybunny3
Copy link
Contributor Author

@danranVm 已更新api

@danranVm
Copy link
Member

#279

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

No branches or pull requests

3 participants