<nav role="navigation" aria-label="anchor-links" class="anchor-links ">
<ul class="anchor-links__inner">
<li>
<a href="#step-1" class="in-page-link">
<span class="anchor-links__label">
Step 1
</span>
<span class="anchor-links__dot"></span>
</a>
</li>
<li>
<a href="#step-2" class="in-page-link">
<span class="anchor-links__label">
Step 2
</span>
<span class="anchor-links__dot"></span>
</a>
</li>
<li>
<a href="#step-3" class="in-page-link">
<span class="anchor-links__label">
Step 3
</span>
<span class="anchor-links__dot"></span>
</a>
</li>
<li>
<a href="#step-4" class="in-page-link">
<span class="anchor-links__label">
Step 4
</span>
<span class="anchor-links__dot"></span>
</a>
</li>
<li>
<a href="#step-5" class="in-page-link">
<span class="anchor-links__label">
Step 5
</span>
<span class="anchor-links__dot"></span>
</a>
</li>
<li>
<a href="#step-6" class="in-page-link">
<span class="anchor-links__label">
Step 6
</span>
<span class="anchor-links__dot"></span>
</a>
</li>
<li>
<a href="#step-7" class="in-page-link">
<span class="anchor-links__label">
Step 7
</span>
<span class="anchor-links__dot"></span>
</a>
</li>
<li>
<a href="#step-8" class="in-page-link">
<span class="anchor-links__label">
Step 8
</span>
<span class="anchor-links__dot"></span>
</a>
</li>
</ul>
</nav>
/* @anchor-links */
.anchor-links {
@media (max-width: $medium-screen) {
display: none !important;
}
background-image: linear-gradient(to left, $blue-ribbon, $regal-blue);
padding: $base-spacing/2 $base-spacing;
top: 120px;
display: block;
z-index: 300;
width: 100%;
position: sticky;
@media screen and (-ms-high-contrast: active), screen and (-ms-high-contrast: none) {
&.fixed {
position: fixed;
}
}
.admin-bar & {
top: 152px;
}
@include themify($themes) {
background-image: linear-gradient(to right, themed('ctaGradient'), themed('ctaColor'));
}
&__inner {
width: 100%;
max-width: $container-width;
margin: 0 auto;
list-style: none;
padding: 0;
li {
display: inline-block;
width: 20%;
&::after {
content: "";
position: absolute;
bottom: 17px;
width: 100%;
left: 0;
height: 1px;
background-color: white;
z-index: 1;
}
&:first-child {
&::after {
width: 50%;
left: 50%;
}
}
&:last-child {
&::after {
width: 50%;
}
}
a {
color: white;
padding: 0 $base-spacing;
text-align: center;
white-space: nowrap;
display: block;
margin: 0 $small-spacing;
font-weight: 400;
font-size: 12px;
position: relative;
z-index: 10;
.is-selected & {
font-weight: 900 !important;
}
&:focus,
&:hover {
color: white;
}
}
}
}
&__label {
display: block;
position: relative;
left: 50%;
transform: translateX(-50%);
overflow: hidden;
text-overflow: ellipsis;
}
&__dot {
display: inline-block;
width: 1rem;
height: 1rem;
margin: 0 8px;
background: #fff;
border-radius: 50%;
cursor: pointer;
border: 2px solid $white;
position: relative;
transition: 0.3s;
.is-selected &, .in-page-link:hover & {
@include themify($themes) {
background-color: themed('ctaColor');
}
}
&::before, &::after {
position: absolute;
top: 50%;
left: 50%;
margin: -18px 0 0 -18px;
width: 36px;
height: 36px;
border-radius: 50%;
content: '';
opacity: 0;
pointer-events: none;
}
&::before,
&::after {
box-shadow: 0 0 0 2px white;
}
.is-selected & {
&::before {
animation: anim-pulse-1 4s forwards;
}
&::after {
animation: anim-pulse-2 4s forwards;
}
}
}
}
/* anchor-links */
import $ from 'jQuery'
import Flickity from 'flickity'
$(document).ready(function () {
let mastheadHeight = $('.masthead').outerHeight()
let totalOffset = mastheadHeight
let didScroll = false
let ieOffset
if ($('.anchor-links').length) {
let anchorHeight = $('.anchor-links').outerHeight()
totalOffset = Number(totalOffset) + Number(anchorHeight)
if ($('.hero').length ) {
let heroHeight = $('.hero').innerHeight()
ieOffset = Number(heroHeight) - (Number(mastheadHeight) * 2)
} else {
ieOffset = 0
$('.browser--ie11 .anchor-links').css('top', mastheadHeight)
}
}
// Select all links with hashes
$('a[href*="#"]').not('[href="#"]').not('[href="#0"]').not('[href="#important-safety-information"]').click(function(event) {
// On-page links
console.log(this)
if (
location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '')
&&
location.hostname == this.hostname
) {
var target = $(this.hash)
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']')
if (target.length) {
let calculateOffset = target.offset().top - totalOffset
let $targetNew = $(target)
event.preventDefault()
if ($(target).find('>div>button').attr('aria-expanded')=='false') {
$(target).find('>div>button').click()
}
// if the mobile nav is open, close it
if ($('.masthead__mobile__main .mobile-nav__toggle--is-open').length) {
$('.masthead__mobile__main .mobile-nav__toggle').click()
}
$('html, body').animate({
scrollTop: calculateOffset
}, 1000, function() {
$targetNew.focus({preventScroll: true})
if ($targetNew.find('.accordion-block')) {
event.stopPropagation()
}
})
if ($targetNew.is(":focus")) { // Checking if the target was focused
return false
} else {
$targetNew.attr('tabindex','-1') // Adding tabindex for elements not focusable
$targetNew.focus({preventScroll: true}) // Set focus again
}
}
}
});
if ($('.anchor-links__inner').length) {
var carousel = new Flickity('.anchor-links__inner', {
prevNextButtons: false,
pageDots: false,
contain: true,
cellAlign: 'center',
})
carousel.on( 'staticClick', function( event, pointer, cellElement, cellIndex ) {
if ( typeof cellIndex == 'number' ) {
carousel.select(cellIndex)
}
})
}
function selectMenu () {
$('.block[id]').not('.block[id=""]').each(function(i, obj) {
let $block = $(this)
let elementTop = $block.offset().top
let elementBottom = elementTop + $block.outerHeight()
let viewportTop = $(window).scrollTop()
let markerOffset = totalOffset + 100
if ( (elementTop - viewportTop ) < markerOffset && elementBottom > (viewportTop + markerOffset) ) {
if ( i !== carousel.selectedIndex ) {
carousel.select(i)
}
}
})
}
$(window).scroll(function() {
didScroll = true;
});
setInterval(function() {
if ( didScroll ) {
didScroll = false;
if ($('.anchor-links__inner').length) {
selectMenu ()
}
/*
if ($(document).scrollTop() > ieOffset) {
$('.anchor-links').addClass('fixed')
} else {
$('.anchor-links').removeClass('fixed')
}
*/
}
}, 100);
})
// $('a[href*=#]:not([href=#])').click(function() {
// if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
// || location.hostname == this.hostname) {
// var target = $(this.hash);
// target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
// if (target.length) {
// $('html,body').animate({
// scrollTop: target.offset().top
// }, 1000);
// return false;
// }
// }
// });