Skip to content

Commit ccf1a98

Browse files
committed
feat: change Fixed status event
1 parent 8f4f096 commit ccf1a98

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/components/ExampleApp.vue

+10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template>
22
<div id="app">
33
<VueFixedHeader
4+
@change="updateFixedStatus"
45
:threshold="propsData.threshold"
56
:headerClass="propsData.headerClass"
67
:fixedClass="propsData.fixedClass"
@@ -49,6 +50,9 @@
4950
<footer>
5051
<el-menu class="footer-content">
5152
<div class="flex-1"></div>
53+
<el-menu-item class="fixed-footer__item" index="1">
54+
<b> isFixed: {{ fixedStatus.headerIsFixed }} </b>
55+
</el-menu-item>
5256
<el-menu-item class="fixed-footer__item" index="1">
5357
<b> threshold: {{ propsData.threshold }} </b>
5458
</el-menu-item>
@@ -80,11 +84,17 @@ export default Vue.extend({
8084
},
8185
data() {
8286
return {
87+
fixedStatus: {
88+
headerIsFixed: false
89+
},
8390
propsData: { ...createData() },
8491
formData: { ...createData() }
8592
}
8693
},
8794
methods: {
95+
updateFixedStatus(next: boolean) {
96+
this.fixedStatus.headerIsFixed = next
97+
},
8898
handleClickUpdate() {
8999
this.propsData = { ...this.formData }
90100
},

src/components/vue-fixed-header.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export default Vue.extend({
4848
const { tag, qs, threshold } = this
4949
if (tag && this.isFixed !== qs(tag).scrollTop > threshold) {
5050
this.isFixed = qs(tag).scrollTop > threshold
51+
this.$emit('change', this.isFixed)
5152
this.$forceUpdate()
5253
}
5354
}

0 commit comments

Comments
 (0)