From 7736db87b41772baafffbc69a4013b187894b218 Mon Sep 17 00:00:00 2001 From: Maurice Williams Date: Tue, 13 Aug 2019 22:41:49 -0400 Subject: [PATCH] fix(VAppBar): fix elevation issue when extended When using **hide-on-scroll** in combination with **extended**, **elevate-on-scroll** would not work as expected. fixes #8516 --- .../vuetify/src/components/VAppBar/VAppBar.ts | 4 +++ .../VAppBar/__tests__/VAppBar.spec.ts | 29 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/packages/vuetify/src/components/VAppBar/VAppBar.ts b/packages/vuetify/src/components/VAppBar/VAppBar.ts index 8c47f77b1282..67d54d2eeae2 100644 --- a/packages/vuetify/src/components/VAppBar/VAppBar.ts +++ b/packages/vuetify/src/components/VAppBar/VAppBar.ts @@ -172,6 +172,10 @@ export default baseMixins.extend({ return this.bottom ? scrollOffScreen : -scrollOffScreen }, hideShadow (): boolean { + if (this.elevateOnScroll && this.isExtended) { + return this.currentScroll < this.computedScrollThreshold + } + if (this.elevateOnScroll) { return this.currentScroll === 0 || this.computedTransform < 0 diff --git a/packages/vuetify/src/components/VAppBar/__tests__/VAppBar.spec.ts b/packages/vuetify/src/components/VAppBar/__tests__/VAppBar.spec.ts index b2ee5f0f5a67..571cf5408ef0 100644 --- a/packages/vuetify/src/components/VAppBar/__tests__/VAppBar.spec.ts +++ b/packages/vuetify/src/components/VAppBar/__tests__/VAppBar.spec.ts @@ -248,4 +248,33 @@ describe('AppBar.ts', () => { expect(wrapper.vm.computedTransform).toBe(0) expect(wrapper.vm.hideShadow).toBe(false) }) + + it('should show shadow when hide-on-scroll and elevate-on-scroll and extended are all true', async () => { + const wrapper = mountFunction({ + propsData: { + hideOnScroll: true, + elevateOnScroll: true, + extended: true + }, + }) + + expect(wrapper.vm.computedTransform).toBe(0) + expect(wrapper.vm.hideShadow).toBe(true) + + await scrollWindow(1000) + + expect(wrapper.vm.computedTransform).toBe(-64) + expect(wrapper.vm.hideShadow).toBe(false) + + await scrollWindow(600) + + expect(wrapper.vm.computedTransform).toBe(0) + expect(wrapper.vm.hideShadow).toBe(false) + + await scrollWindow(0) + + expect(wrapper.vm.computedTransform).toBe(0) + expect(wrapper.vm.hideShadow).toBe(true) + + }) })