Skip to content

Commit

Permalink
fix: vue-scrollactive initial selected item determined by hash in URL…
Browse files Browse the repository at this point in the history
… or uses default as fallback
  • Loading branch information
matthamil committed Mar 18, 2021
1 parent 8c07b7b commit 6fb9f40
Showing 1 changed file with 16 additions and 33 deletions.
49 changes: 16 additions & 33 deletions patches/vue-scrollactive+0.9.3.patch
Original file line number Diff line number Diff line change
@@ -1,43 +1,26 @@
diff --git a/node_modules/vue-scrollactive/dist/vue-scrollactive.min.js b/node_modules/vue-scrollactive/dist/vue-scrollactive.min.js
index cfc4ecb..024dca4 100644
index cfc4ecb..6741180 100644
--- a/node_modules/vue-scrollactive/dist/vue-scrollactive.min.js
+++ b/node_modules/vue-scrollactive/dist/vue-scrollactive.min.js
@@ -243,19 +243,21 @@
},
},
mounted: function () {
- var t = window.MutationObserver || window.WebKitMutationObserver;
- this.observer ||
- ((this.observer = new t(this.initScrollactiveItems)),
- this.observer.observe(this.$refs['scrollactive-nav-wrapper'], {
- childList: !0,
- subtree: !0,
- })),
- this.initScrollactiveItems(),
- this.removeActiveClass(),
@@ -252,10 +252,16 @@
})),
this.initScrollactiveItems(),
this.removeActiveClass(),
- (this.currentItem = this.getItemInsideWindow()),
- this.currentItem && this.currentItem.classList.add(this.activeClass),
- this.scrollOnStart && this.scrollToHashElement(),
- this.scrollContainer.addEventListener('scroll', this.onScroll);
+ setTimeout(() => {
+ var t = window.MutationObserver || window.WebKitMutationObserver;
+ this.observer ||
+ ((this.observer = new t(this.initScrollactiveItems)),
+ this.observer.observe(this.$refs['scrollactive-nav-wrapper'], {
+ childList: !0,
+ subtree: !0,
+ })),
+ this.initScrollactiveItems(),
+ this.removeActiveClass(),
+ (this.currentItem = this.getItemInsideWindow()),
+ this.currentItem && this.currentItem.classList.add(this.activeClass),
+ this.scrollOnStart && this.scrollToHashElement(),
+ this.scrollContainer.addEventListener('scroll', this.onScroll);
+ }, 50)
+ (this.currentItem = Array.from(this.items)
+ .find(
+ function(item) {
+ return item.hash === window.location.hash
+ }) || this.getItemInsideWindow()
+ ),
this.currentItem && this.currentItem.classList.add(this.activeClass),
this.scrollOnStart && this.scrollToHashElement(),
this.scrollContainer.addEventListener('scroll', this.onScroll);
+ window.COMPONENT = this
},
updated: function () {
this.initScrollactiveItems();
@@ -382,9 +384,7 @@
@@ -382,9 +388,7 @@
}
},
pushHashToUrl: function (t) {
Expand Down

0 comments on commit 6fb9f40

Please sign in to comment.