Theme
Waypoint
An example with a sticky menubar and "back to top" link. Try to scroll down and see how the menubar gets stuck at top and the link appears at bottom right. Scroll up and see how the menubar gets unstuck and the link disappears. The Waypoint component self is used in combination with pe:javascript. In the callback function we check the current scrolling direction and set "sticky" style class on the current waypoint object.
Source

<h:panelGroup id="wrapper" layout="block">
    <h1>Sticky Menubar and "Back to top" Link</h1>        

    <h:panelGroup id="main-nav-holder" layout="block">
        <p:menubar id="menubar">
            <p:menuitem value="File" url="#" icon="ui-icon-document"/>
            <p:menuitem value="New" url="#" icon="ui-icon-contact"/>
            <p:menuitem value="Edit" url="#" icon="ui-icon-pencil"/>
            <p:menuitem value="Help" url="#" icon="ui-icon-help"/>
            <p:menuitem value="Actions" url="#" icon="ui-icon-gear"/>
            <p:menuitem value="Quit" url="#" icon="ui-icon-close"/>
        </p:menubar>
    </h:panelGroup>

    <h:panelGroup id="container" layout="block">
        <div>
            <h1>Lorem Ipsum Dolor</h1>
            <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
               Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit
               amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet
               est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit
               amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus
               lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus
               faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi,
               tincidunt quis, accumsan porttitor, facilisis luctus, metus</p>
        </div>
        <div>
            <h1>Sit Amet</h1>
            <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum
               tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas
               semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
        </div>
        <div>
            <h1>Consectetuer Adipiscing Elit</h1>
            <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>
        </div>
        <div>
            <h1>Aenean</h1>
            <p>Pellentesque fermentum dolor. Aliquam quam lectus, facilisis auctor, ultrices ut, elementum vulputate,
               nunc. Adid habitant morbi tristique senectus et netus et malesuada, ghrer solid base el dcdw.</p>
            <p>Aliquam tincidunt mauris eu risus.</p>
        </div>
        <div>
            <h1>Vestibulum</h1>
            <p>Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat.
               Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus.</p>
            <p>Phasellus ultrices nulla quis nibh. Quisque a lectus. Donec consectetuer ligula vulputate sem tristique
               cursus. Nam nulla quam, gravida non, commodo a, sodales sit amet, nisi.</p>
        </div>
        <div>
            <h1>Lorem Ipsum Dolor</h1>
            <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum
               tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas
               semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien
               ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi.
               Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui.
               Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor
               neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis,
               accumsan porttitor, facilisis luctus, metus</p>
        </div>
        <div>
            <h1>Sit Amet</h1>
            <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum
               tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas
               semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
        </div>
        <div>
            <h1>Consectetuer Adipiscing Elit</h1>
            <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>
        </div>
        <div>
            <h1>Aenean</h1>
            <p>Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat.
               Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus.</p>
            <p>Aliquam tincidunt mauris eu risus.</p>
        </div>
        <div>
            <h1>Vestibulum</h1>
            <p>Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat.
               Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus.</p>
            <p>Phasellus ultrices nulla quis nibh. Quisque a lectus. Donec consectetuer ligula vulputate sem tristique
               cursus. Nam nulla quam, gravida non, commodo a, sodales sit amet, nisi.</p>
        </div>
        <div>
            <h1>Lorem Ipsum Dolor</h1>
            <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
               Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet
               quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est
               et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet,
               wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus
               enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus
               faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi,
               tincidunt quis, accumsan porttitor, facilisis luctus, metus</p>
        </div>
        <div>
            <h1>Sit Amet</h1>
            <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum
               tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas
               semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
        </div>
        <div>
            <h1>Consectetuer Adipiscing Elit</h1>
            <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>
        </div>
        <div>
            <h1>Aenean</h1>
            <p>Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat.
               Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus.</p>
            <p>Aliquam tincidunt mauris eu risus.</p>
        </div>
        <div>
            <h1>Vestibulum</h1>
            <p>Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat.
               Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus.</p>
            <p>Phasellus ultrices nulla quis nibh. Quisque a lectus. Donec consectetuer ligula vulputate sem tristique
               cursus. Nam nulla quam, gravida non, commodo a, sodales sit amet, nisi.</p>
        </div>
    </h:panelGroup>

    <p:commandButton id="topLink" type="button" value="TOP" icon="ui-icon-triangle-1-n" styleClass="top hidden"
                     title="Back to top" onclick="$('html, body').animate({scrollTop: 0}, 'fast');"/>
</h:panelGroup>

<pe:waypoint id="waypoint1" for="wrapper" offset="'-100%'">
    <pe:javascript event="reached" execute="$('#topLink').toggleClass('hidden', ext.direction === 'up');"/>
</pe:waypoint>

<pe:waypoint id="waypoint2" for="main-nav-holder">
    <pe:javascript event="reached" execute="$(ext.waypoint).toggleClass('sticky', ext.direction === 'down');"/>
</pe:waypoint>

<h:outputStylesheet id="waypointCSS">
    #wrapper {
        width: 560px;
        margin: 0 auto;
    }
    
    #menubar {
        width: 560px;
    }
    
    .sticky #menubar {
        position: fixed;
        top: 0;
    }
    
    #container {
        margin-bottom: 20px;
    }
    
    .top {
        position: fixed;
        right: 20px;
        bottom: 20px;
        font-size: 14px;
        box-shadow: 0 0 15px 1px #808080;
    }
    
    .top.hidden {
        display: none;
    }
</h:outputStylesheet>
            
Components and more
Documentation pe:waypoint
Attributes (move mouse over the names to see data types)
Name Description
id Unique identifier of the component in a namingContainer.
rendered Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding An EL expression referring to a server side UIComponent instance in a backing bean.
widgetVar Name of the client side widget.
for The target component registered as waypoint. If null, the parent component will be taken as target. Default is null.
forContext The context defines which scrollable element the waypoint belongs to and acts within. It can be a component or plain HTML element like a div. Default is window if nothing specified.
enabled If false, this waypoint will be created but will be disabled from triggering. You can call widget's method "enable" to turn it back on. Default is true.
horizontal Default waypoints live on the vertical axis. Their offset is calculated in relation to the top of the viewport and they listen for vertical scroll changes. If horizontal is set to true, offset is calculated in relation to the left of the viewport and listens for horizontal scroll changes. For instance, the value 50 means "when the left side of this element reaches 50px from the left side of the viewport". Default is false.
offset This option determines how far the top of the element must be from the top of the viewport to trigger a waypoint (callback function). It can be a number, which is taken as a number of pixels (can be also negativ, e.g. -10), a string representing a percentage of the viewport height (e.g. '50%') or a function that will return a number of pixels. Default is 0.
continuous If true, and multiple waypoints are triggered in one scroll, this waypoint will trigger even if it is not the last waypoint reached. If false, it will only trigger if it is the last waypoint. Default is true.
triggerOnce If true, the waypoint will be destroyed when triggered. Default is false.
Events (move mouse over the names to see classes)
Name Description
reachedfired when the user scrolls past the element.
PrimeFaces Extensions Showcase - © 2011-2021,PrimeFaces: 11.0.0,PrimeFaces Extensions: 11.0.0,JSF: Apache MyFaces JSF-2.3 Core API 2.3.9,Server: jetty/9.4.36.v20210114,Build time: 2021-12-10 14:32
occured!