@vaadin-component-factory/vcf-anchor-nav
Advanced tools
Comparing version 1.2.0-beta.2 to 1.2.0-beta.3
{ | ||
"name": "@vaadin-component-factory/vcf-anchor-nav", | ||
"version": "1.2.0-beta.2", | ||
"version": "1.2.0-beta.3", | ||
"description": "Component with tabs used as anchor navigation and content sections. Automates the linking of tabs and sections.", | ||
@@ -5,0 +5,0 @@ "main": "vcf-anchor-nav.js", |
@@ -142,3 +142,3 @@ import { html, PolymerElement } from '@polymer/polymer/polymer-element'; | ||
static get version() { | ||
return '1.2.0-beta.2'; | ||
return '1.2.0-beta.3'; | ||
} | ||
@@ -240,3 +240,6 @@ | ||
this._initTabHighlight(); | ||
if (this._deepLinks) this._scrollToHash(); | ||
if (this.selectedId) this._scrollToSection(this.selectedId); | ||
else if (this._deepLinks) this._scrollToHash(); | ||
// Dispatch sections-ready event | ||
this.dispatchEvent(new CustomEvent('sections-ready', { detail: this.sections })); | ||
} | ||
@@ -328,3 +331,11 @@ } | ||
const firstIntersecting = this.sections.filter(i => i.isIntersecting)[0]; | ||
if (firstIntersecting) this.selectedIndex = this._getTabIndex(firstIntersecting.id); | ||
if (firstIntersecting) { | ||
if (!this._firstUpdate) { | ||
// Prevent overwriting selected index on first update | ||
if (!this.selectedId && !this.selectedIndex) this.selectedIndex = this._getTabIndex(firstIntersecting.id); | ||
this._firstUpdate = true; | ||
} else { | ||
this.selectedIndex = this._getTabIndex(firstIntersecting.id); | ||
} | ||
} | ||
} | ||
@@ -368,4 +379,3 @@ | ||
_getSectionId(sectionIndex) { | ||
const tab = this.$.tabs.querySelectorAll('vaadin-tab')[sectionIndex]; | ||
return (tab && tab.dataset.sectionId) || ''; | ||
return this.sections[sectionIndex].id; | ||
} | ||
@@ -372,0 +382,0 @@ |
215720
2243