-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
feat: scroll to end input element #3293
Conversation
Signed-off-by: Innei <[email protected]>
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Signed-off-by: Innei <[email protected]>
直接给个 srollTo 吧,对 input 和 textarea 都生效,toend 太局限了 |
Signed-off-by: Innei <[email protected]>
Signed-off-by: Innei <[email protected]>
src/input/src/Input.tsx
Outdated
function scrollToEnd (animated = true): void { | ||
const { value: textareaEl } = textareaElRef | ||
if (!textareaEl) { | ||
return | ||
} | ||
|
||
const { scrollHeight, scrollTop, clientHeight } = textareaEl | ||
const end = scrollHeight - clientHeight | ||
if (end === scrollTop) { | ||
return | ||
} | ||
scrollTo({ | ||
top: end, | ||
behavior: animated ? 'smooth' : 'auto' | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个删了吧,别暴露这种
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
因为已经有能用的了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可
Signed-off-by: Innei <[email protected]>
src/input/demos/zhCN/focus.demo.vue
Outdated
handleScrollEnd () { | ||
inputInstRef.value?.scrollTo({ | ||
behavior: 'smooth', | ||
top: inputInstRef.value?.textareaElRef?.scrollHeight |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这种不需要这么干净,写个 10000 就好了
Signed-off-by: Innei [email protected]
closes #3280