fix(select): onScroll

This commit is contained in:
07akioni 2020-10-30 15:48:45 +08:00
parent cb5ad4bf32
commit df52cffbf3
6 changed files with 25 additions and 30 deletions

View File

@ -76,10 +76,10 @@ export default {
}
},
methods: {
handleScroll (e, scrollContainer, scrollContent) {
this.scrollContentHeight = scrollContent.offsetHeight
this.scrollContainerScrollTop = scrollContainer.scrollTop
this.scrollContainerHeight = scrollContainer.offsetHeight
handleScroll (e) {
this.scrollContentHeight = e.target.firstElementChild.offsetHeight
this.scrollContainerScrollTop = e.target.scrollTop
this.scrollContainerHeight = e.target.offsetHeight
}
}
}
@ -87,6 +87,5 @@ export default {
```css
.n-select {
width: 180px;
margin: 0 12px 8px 0;
}
```

View File

@ -76,10 +76,10 @@ export default {
}
},
methods: {
handleScroll (e, scrollContainer, scrollContent) {
this.scrollContentHeight = scrollContent.offsetHeight
this.scrollContainerScrollTop = scrollContainer.scrollTop
this.scrollContainerHeight = scrollContainer.offsetHeight
handleScroll (e) {
this.scrollContentHeight = e.target.firstElementChild.offsetHeight
this.scrollContainerScrollTop = e.target.scrollTop
this.scrollContainerHeight = e.target.offsetHeight
}
}
}
@ -87,6 +87,5 @@ export default {
```css
.n-select {
width: 180px;
margin: 0 12px 8px 0;
}
```

View File

@ -27,8 +27,8 @@
:item-size="itemSize"
:show-scrollbar="false"
:default-scroll-index="defaultScrollIndex"
@resize="handleListResize"
@scroll="handleListScroll"
@resize="handleVirtualListResize"
@scroll="handleVirtualListScroll"
>
<template v-slot="{ item: tmNode }">
<n-select-group-header
@ -148,12 +148,12 @@ export default {
type: Boolean,
default: true
},
// deprecated
onMenuToggleOption: {
onScroll: {
type: Function,
default: undefined
},
onMenuScroll: {
// deprecated
onMenuToggleOption: {
type: Function,
default: undefined
}
@ -234,15 +234,16 @@ export default {
},
doScroll (e) {
const {
onMenuScroll
onScroll
} = this
if (onMenuScroll) onMenuScroll(e)
if (onScroll) onScroll(e)
},
// required, scroller sync need to be triggered manually
handleListScroll () {
handleVirtualListScroll (e) {
this.scrollbarRef.sync()
this.doScroll(e)
},
handleListResize () {
handleVirtualListResize () {
this.scrollbarRef.sync()
},
getPendingOption () {

View File

@ -381,7 +381,7 @@ export default {
const {
onScroll
} = this
if (onScroll) onScroll(e, this.mergedContainerRef(), this.mergedContentRef())
if (onScroll) onScroll(e)
this.syncScrollState()
},
syncScrollState () {

View File

@ -77,7 +77,7 @@
:filterable="filterable"
:value="value"
@menu-toggle-option="handleToggleOption"
@menu-scroll="handleMenuScroll"
@scroll="handleMenuScroll"
>
<template v-if="$slots.empty" v-slot:empty>
<slot name="empty" />

14
vue3.md
View File

@ -239,18 +239,13 @@ placeable 进行了大调整
- `on-change` is now a native event
- [x] result
- [x] scrollbar
- TODO
- [ ] scrollTo
- [ ] select
- [x] select
- break
- `v-model` => `v-model:value`
- `on-scroll(event, container, content)` => `on-scroll(event)`
- `option.render(h, data)` => `option.render(data)`
- deprecated
- `on-change` => `on-update:value`
- TODO
- [ ] `on-scroll`
- [x] render item
- [ ] keyboard scroll when non virtual
- [ ] auto pending selected option
- [x] slider
- deprecated
- `on-change` => `on-update:value`
@ -313,5 +308,6 @@ placeable 进行了大调整
- tusimple theme
- clean delegate
- site production tag (bug)
- demo scrollbar 的问题
- [x] demo scrollbar 的问题
- table x scroll 右侧阴影不消失
- [x] log scrollTo 有点问题