Package com.vaadin.componentfactory
Class AnchorNav
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.HtmlComponent
com.vaadin.flow.component.HtmlContainer
com.vaadin.componentfactory.AnchorNav
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasComponents,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasText,com.vaadin.flow.component.HasTheme,Serializable
@Tag("vcf-anchor-nav")
@NpmPackage(value="@vaadin-component-factory/vcf-anchor-nav",
version="4.0.0")
@JsModule("@vaadin-component-factory/vcf-anchor-nav")
public class AnchorNav
extends com.vaadin.flow.component.HtmlContainer
implements com.vaadin.flow.component.HasTheme
Server-side component for the
vcf-anchor-nav element.- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface com.vaadin.flow.component.HasText
com.vaadin.flow.component.HasText.WhiteSpace -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.RegistrationaddRealignOnEvent(String eventName) Registers a listener that re-aligns the view to the currently selected section (seescrollToSelectedSection()) whenever a DOM event with the given name is fired on, or bubbles up to, this component.addSection(com.vaadin.flow.component.tabs.Tab sectionTab, com.vaadin.flow.component.Component... components) Adds a section created from the given Tab and content.addSection(String title, com.vaadin.flow.component.Component... components) Adds a section created from the given title and content.com.vaadin.flow.shared.RegistrationaddSelectedSectionChangedListener(com.vaadin.flow.component.ComponentEventListener<AnchorNav.SelectedSectionChangedEvent> listener) Adds a listener forAnchorNav.SelectedSectionChangedEvent.voidaddThemeVariants(AnchorNavVariant... variants) Adds theme variants to the component.voidscrollToSection(int sectionIndex) Scrolls the section with the given zero-based index to the top of the navigation area without changing which tab is selected.voidscrollToSection(AnchorNavSection section) Scrolls the given section to the top of the navigation area without changing which tab is selected.voidRe-scrolls to the section most recently selected withsetSelectedSection(int)orsetSelectedSection(AnchorNavSection).voidsetHeader(com.vaadin.flow.component.Component header) Sets the component headervoidsetHeaderText(String headerText) Set the header text as a html h2 titlevoidsetNoHistory(boolean noHistory) Toggles "no history" mode for the anchor.voidsetSelectedSection(int selectedIndex) Selects a section based on its zero-based index.voidsetSelectedSection(AnchorNavSection selectedSection) Selects the given section.Methods inherited from class com.vaadin.flow.component.HtmlComponent
getTitle, setTitleMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasComponents
add, add, add, addComponentAsFirst, addComponentAtIndex, remove, remove, removeAllMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasText
getText, getWhiteSpace, setText, setWhiteSpaceMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName
-
Constructor Details
-
AnchorNav
public AnchorNav() -
AnchorNav
public AnchorNav(boolean noHistory)
-
-
Method Details
-
setNoHistory
public void setNoHistory(boolean noHistory) Toggles "no history" mode for the anchor. Setting the property for a single AnchorNav enabled "no history" mode for the entire view.- Parameters:
noHistory-
-
addSection
Adds a section created from the given title and content.- Parameters:
title- title of the sectioncomponents- content- Returns:
- the section
-
addSection
public AnchorNavSection addSection(com.vaadin.flow.component.tabs.Tab sectionTab, com.vaadin.flow.component.Component... components) Adds a section created from the given Tab and content.- Parameters:
sectionTab- Tab of the sectioncomponents- content- Returns:
- the section
-
setHeaderText
Set the header text as a html h2 title- Parameters:
headerText- text of the header
-
setHeader
public void setHeader(com.vaadin.flow.component.Component header) Sets the component header- Parameters:
header- component to add as a header
-
setSelectedSection
public void setSelectedSection(int selectedIndex) Selects a section based on its zero-based index.- Parameters:
selectedIndex- the zero-based index of the selected section
-
scrollToSection
public void scrollToSection(int sectionIndex) Scrolls the section with the given zero-based index to the top of the navigation area without changing which tab is selected. SeescrollToSection(AnchorNavSection)for when and why to use this.- Parameters:
sectionIndex- the zero-based index of the section to scroll to
-
scrollToSelectedSection
public void scrollToSelectedSection()Re-scrolls to the section most recently selected withsetSelectedSection(int)orsetSelectedSection(AnchorNavSection).Convenience for the common case where you want to re-align to the programmatically selected section without keeping a reference to it - for example from a "content loaded" listener after lazy-loaded content above it has settled. Equivalent to calling
scrollToSection(int)with the last selected index. Has no effect if no section has been selected programmatically yet. -
addRealignOnEvent
Registers a listener that re-aligns the view to the currently selected section (seescrollToSelectedSection()) whenever a DOM event with the given name is fired on, or bubbles up to, this component.This is the recommended way to correct the scroll position after content above the selected section finishes loading or resizing, without having to wire a listener through
Component.getElement()yourself: have your loading logic dispatch a (bubbling) DOM event once the content has settled, and pass its name here.anchorNav.setSelectedSection(details); anchorNav.addRealignOnEvent("content-loaded"); // on the client, once lazy loading is done, e.g.: // grid.dispatchEvent(new CustomEvent('content-loaded', { bubbles: true }));- Parameters:
eventName- the name of the DOM event that signals content is ready, notnull- Returns:
- a registration for removing the listener
-
addSelectedSectionChangedListener
public com.vaadin.flow.shared.Registration addSelectedSectionChangedListener(com.vaadin.flow.component.ComponentEventListener<AnchorNav.SelectedSectionChangedEvent> listener) Adds a listener forAnchorNav.SelectedSectionChangedEvent.- Parameters:
listener- the listener to add, notnull- Returns:
- a handle that can be used for removing the listener
-