0

I am trying to make the dots on my webpage follow the change in pages as I scroll. Right now, I am only able to make the dots, together with the page change when I click on it. Below is my code.

$('.dot-nav--item').on('click', function() {
  $this = $(this),
    $siblings = $this.siblings();

  $this.addClass('is-active');
  $siblings.removeClass('is-active');
})
body {
  background-color: rgb(200, 200, 200);
  font-family: open sans;
  padding: 0;
  margin: 0;
}

.dot-nav {
  position: fixed;
  top: 50%;
  left: 95%;
  transform: translate(-50%, -50%);
  z-index: 99999;
}


/* Fin Init */

.dot-nav--item {
  position: relative;
  display: block;
  width: 16px;
  height: 16px;
  margin-bottom: 24px;
  border: 3px solid #fff;
  border-radius: 50%;
}

.dot-nav--item:before,
.dot-nav--item:after {
  content: "";
}

.dot-nav--item:before {
  position: absolute;
  top: -1px;
  bottom: -1px;
  left: -1px;
  right: -1px;
  transform: scale(0);
  opacity: 0;
  border-radius: 50%;
  background-color: #fff;
  transition: all .3s;
}

.dot-nav--item:after {
  display: block;
  width: 3px;
  height: 30px;
  margin: 16px auto 0;
  background-color: #fff;
}

.dot-nav--item:last-child:after {
  display: none;
}

.dot-nav--item:hover {
  cursor: pointer;
}

.dot-nav--item.is-active:before {
  opacity: 1;
  transform: scale(1);
}

.dot-nav--link {
  position: absolute;
  top: 50%;
  visibility: hidden;
  transform: translate(-120%, -50%);
  width: 200px;
  padding: 5px 10px;
  opacity: 0;
  color: #111;
  background-color: #fff;
  transition: all .3s;
}

.dot-nav--link:before {
  content: "";
  position: absolute;
  top: 50%;
  left: 100%;
  width: 0;
  height: 0;
  border-width: 6px 0 6px 8px;
  border-color: transparent transparent transparent #fff;
  border-style: solid;
  transform: translateY(-50%);
}

.dot-nav--item:hover .dot-nav--link {
  visibility: visible;
  opacity: 1;
  transform: translate(-110%, -50%);
}

#page0 {
  height: 80vw;
  background: url("smarthome.JPG") no-repeat top center fixed;
  background-size: cover;
  margin-bottom: -9em;
}

#page1 {
  height: 80vw;
  background: url("retail.JPG") no-repeat top center fixed;
  background-size: cover;
  margin-bottom: -9em;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div id="page0"></div>
<div id="page1"></div>

<nav class="dot-nav">
  <ul class="dot-nav--list list-unstyled">
    <li class="dot-nav--item is-active"><a href="readmore1.html#page0" class="dot-nav--link">Introduction</a></li>
    <li class="dot-nav--item"><a href="readmore1.html#page1" class="dot-nav--link">Smart Home</a></li>
  </ul>
</nav>

I am not sure how to make the dots fill as I scroll through the pages, do you have any ideas? Thanks in advance.

Reinstate Monica Cellio
  • 25,420
  • 6
  • 49
  • 67
Jamie
  • 85
  • 1
  • 8
  • I can't see any dots at all – Claudio Jan 05 '18 at 10:48
  • 1
    https://stackoverflow.com/questions/20276166/how-do-i-make-my-navbar-change-css-class-upon-scrolling-past-an-anchor-point, https://stackoverflow.com/questions/14161132/jquery-scroll-change-navigation-active-class-as-the-page-is-scrolling-relative – Pete Jan 05 '18 at 10:54

0 Answers0