Funny example of Waypoints within scrollable non-window elements.
The Waypoint component utilizes the "forContext" attribute and is used in combination with pe:javascript.
Font Size:
- 8px
- 10px
- 12px
- 14px
- 16px
- 18px
- 24px
- 36px
- 48px
- 72px
Width:
- 150px
- 200px
- 250px
- 300px
- 350px
- 400px
- 500px
- 600px
- 700px
- 800px
- 1024px
- 1280px
BG Color:
- #fff
- #d1f2a5
- #effab4
- #ffc48c
- #ff9f80
- #f56991
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur blandit ultrices rutrum. Cras dignissim purus non purus
mattis nec lobortis enim dignissim. Nulla a urna est. Proin volutpat odio id velit tempor sollicitudin. Aliquam lobortis
nunc gravida orci fringilla in commodo lectus gravida. In hac habitasse platea dictumst. Maecenas tincidunt pulvinar
blandit. Suspendisse a diam ligula. Mauris non tellus nisl, in interdum elit. Etiam rhoncus cursus lectus vel venenatis.
Nulla facilisi. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Integer
eleifend imperdiet lectus vitae aliquet. Mauris metus lorem, fermentum vitae malesuada quis, pretium id mi.
Source
<h:panelGroup id="wrapper" layout="block">
<div data-property="font-size" class="dial first">
<h3>Font Size:</h3>
<ul>
<li data-value="8px">8px</li>
<li data-value="10px">10px</li>
<li data-value="12px">12px</li>
<li data-value="14px">14px</li>
<li data-value="16px">16px</li>
<li data-value="18px">18px</li>
<li data-value="24px">24px</li>
<li data-value="36px">36px</li>
<li data-value="48px">48px</li>
<li data-value="72px">72px</li>
</ul>
<div class="indicator"></div>
</div>
<div data-property="width" class="dial">
<h3>Width:</h3>
<ul>
<li data-value="150px">150px</li>
<li data-value="200px">200px</li>
<li data-value="250px">250px</li>
<li data-value="300px">300px</li>
<li data-value="350px">350px</li>
<li data-value="400px">400px</li>
<li data-value="500px">500px</li>
<li data-value="600px">600px</li>
<li data-value="700px">700px</li>
<li data-value="800px">800px</li>
<li data-value="1024px">1024px</li>
<li data-value="1280px">1280px</li>
</ul>
<div class="indicator"></div>
</div>
<div data-property="background-color" class="dial">
<h3>BG Color:</h3>
<ul>
<li data-value="#fff">#fff</li>
<li data-value="#d1f2a5">#d1f2a5</li>
<li data-value="#effab4">#effab4</li>
<li data-value="#ffc48c">#ffc48c</li>
<li data-value="#ff9f80">#ff9f80</li>
<li data-value="#f56991">#f56991</li>
</ul>
<div class="indicator"></div>
</div>
</h:panelGroup>
<h:panelGroup id="textContainer" layout="block">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur blandit ultrices rutrum. Cras dignissim purus non purus
mattis nec lobortis enim dignissim. Nulla a urna est. Proin volutpat odio id velit tempor sollicitudin. Aliquam lobortis
nunc gravida orci fringilla in commodo lectus gravida. In hac habitasse platea dictumst. Maecenas tincidunt pulvinar
blandit. Suspendisse a diam ligula. Mauris non tellus nisl, in interdum elit. Etiam rhoncus cursus lectus vel venenatis.
Nulla facilisi. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Integer
eleifend imperdiet lectus vitae aliquet. Mauris metus lorem, fermentum vitae malesuada quis, pretium id mi.
</h:panelGroup>
<pe:waypoint id="waypoint" for="@(.dial li)" forContext="@(.dial ul)" offset="25">
<pe:javascript event="reached" execute="handleWaypoint(ext);"/>
</pe:waypoint>
<h:outputScript id="waypointScript" target="body">
/* <![CDATA[ */
function handleWaypoint(ext) {
var $active = $(ext.waypoint);
if (ext.direction === "up") {
$active = $active.prev();
}
if (!$active.length) $active.end();
var cssProperty = $active.closest('.dial').data('property');
var cssValue = $active.data('value');
if (cssProperty && cssValue) {
$('#textContainer').css(cssProperty, cssValue);
}
}
/* ]]> */
</h:outputScript>
<h:outputStylesheet id="waypointCSS">
#wrapper {
width: 460px;
margin: 0 auto 0 auto;
overflow: hidden;
}
.dial {
float: left;
width: 140px;
margin-left: 20px;
position: relative;
}
.dial.first {
margin-left: 0;
}
.dial h2 {
font-weight: bold;
}
.dial ul {
background: #fff;
border: 1px solid #bbb;
padding: 25px 0 114px 0;
height: 1px;
overflow-y: scroll;
margin: 0;
}
.dial ul:before {
content: "";
border: 10px solid #555;
width: 1px;
height: 1px;
display: block;
position: absolute;
bottom: 105px;
left: 0;
z-index: 3;
border-top-color: transparent;
border-right-color: transparent;
border-bottom-color: transparent;
}
.dial li {
height: 20px;
line-height: 20px;
padding: 10px 10px 10px 20px;
border-bottom: 1px solid #ddd;
font-size: 20px;
margin: 0;
}
.dial li:first-child {
border-top: 1px solid #ddd;
}
li[data-value="#fff"] {
background: #fff;
}
li[data-value="#d1f2a5"] {
background: #d1f2a5;
}
li[data-value="#effab4"] {
background: #effab4;
}
li[data-value="#ffc48c"] {
background: #ffc48c;
}
li[data-value="#ff9f80"] {
background: #ff9f80;
}
li[data-value="#f56991"] {
background: #f56991;
}
.indicator {
position: absolute;
bottom: 115px;
left: 0;
height: 1px;
width: 120px;
background: red;
}
#textContainer {
font-size: 8px;
line-height: 1.5;
width: 150px;
background: #fff;
border: 1px solid #ccc;
margin: 15px auto auto auto;
padding: 10px;
-webkit-transition: all 500ms ease-in-out;
-moz-transition: all 500ms ease-in-out;
-ms-transition: all 500ms ease-in-out;
transition: all 500ms ease-in-out;
}
</h:outputStylesheet>