Skip to content

Commit

Permalink
feat: change Fixed status event
Browse files Browse the repository at this point in the history
  • Loading branch information
potato4d committed Mar 3, 2019
1 parent 8f4f096 commit ccf1a98
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/components/ExampleApp.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div id="app">
<VueFixedHeader
@change="updateFixedStatus"
:threshold="propsData.threshold"
:headerClass="propsData.headerClass"
:fixedClass="propsData.fixedClass"
Expand Down Expand Up @@ -49,6 +50,9 @@
<footer>
<el-menu class="footer-content">
<div class="flex-1"></div>
<el-menu-item class="fixed-footer__item" index="1">
<b> isFixed: {{ fixedStatus.headerIsFixed }} </b>
</el-menu-item>
<el-menu-item class="fixed-footer__item" index="1">
<b> threshold: {{ propsData.threshold }} </b>
</el-menu-item>
Expand Down Expand Up @@ -80,11 +84,17 @@ export default Vue.extend({
},
data() {
return {
fixedStatus: {
headerIsFixed: false
},
propsData: { ...createData() },
formData: { ...createData() }
}
},
methods: {
updateFixedStatus(next: boolean) {
this.fixedStatus.headerIsFixed = next
},
handleClickUpdate() {
this.propsData = { ...this.formData }
},
Expand Down
1 change: 1 addition & 0 deletions src/components/vue-fixed-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default Vue.extend({
const { tag, qs, threshold } = this
if (tag && this.isFixed !== qs(tag).scrollTop > threshold) {
this.isFixed = qs(tag).scrollTop > threshold
this.$emit('change', this.isFixed)
this.$forceUpdate()
}
}
Expand Down

0 comments on commit ccf1a98

Please sign in to comment.