JSFiddle - React, Tailwind, and code Playground

by Richard Hunter

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<div class="wp-block-column" style="flex-basis:66.66%">
  <span id="titre-h2" class="uag-toc__heading-anchor"></span>
  <h2 id="1-de-ere-rzer">Titre H2</h2>
  <p>est simplement du faux texte employé dans la composition et la mise en page avant impression. Le Lorem Ipsum est le faux texte standard de l’imprimerie depuis les années 1500, quand un imprimeur anonyme assembla ensemble des morceaux de texte pour réa.</p>
  <p>implement du faux texte employé dans la composition et la mise en page avant impression. Le Lorem Ipsum est le faux texte standard de l’imprimerie depuis les années 1500, quand un imprimeur anonyme assembla ensemble des morceaux de texte pour réa.</p>
  <p>implement du faux texte employé dans la composition et la mise en page avant impression. Le Lorem Ipsum est le faux texte standard de l’imprimerie depuis les années 1500, quand un imprimeur anonyme assembla ensemble des morceaux de texte pour réa.</p>
  <p>implement du faux texte employé dans la composition et la mise en page avant impression. Le Lorem Ipsum est le faux texte standard de l’imprimerie depuis les années 1500, quand un imprimeur anonyme assembla ensemble des morceaux de texte pour réa.</p>

  <span id="titre-h3" class="uag-toc__heading-anchor"></span>
  <h3>Titre H3</h3>
  <p>implement du faux texte employé dans la composition et la mise en page avant impression. Le Lorem Ipsum est le faux texte standard de l’imprimerie depuis les années 1500, quand un imprimeur anonyme assembla ensemble des morceaux de texte pour réa.</p>
  <p>implement du faux texte employé dans la composition et la mise en page avant impression. Le Lorem Ipsum est le faux texte standard de l’imprimerie depuis les années 1500, quand un imprimeur anonyme assembla ensemble des morceaux de texte pour réa.</p>
  <p>implement du faux texte employé dans la composition et la mise en page avant impression. Le Lorem Ipsum est le faux...

SCSS

.wp-block-uagb-table-of-contents {
  margin-top: 2rem;
  background-color: white;
}

.uagb-toc__list-wrap {
  position: fixed;
  top: 50%;
  right: 60px;
  transform: translateY(-50%);
}

ul.uagb-toc__list {
  margin: 0;
  color: #002c52;
  background: antiquewhite;
  padding: 0 30px;
}

li {
  list-style: none;
  display: block;
  text-align: right;
  opacity: 0.5;
  padding: 1vh 0;
  cursor: pointer;
  transition: all 0.4s ease;
  transform-origin: 100% 50%;
  transform: scale(0.9);
  text-shadow: 1px 1px 9px #fff, 1px 1px 4px #fff;
}

li a {
  color: blue;
  font-weight: 700;
  text-decoration: none;
}

li.current a {
  font-weight: bold;
  color: red;
  opacity: 1;
  transform: scale(1);
}

#menu_slider {
  position: absolute;
  width: 2px;
  height: 100%;
  left: 0;
  top: 0;
  background: rgba(0, 44, 82, 0.4);
}

#menu_slider_circle {
  position: absolute;
  top: 0%;
  left: 1px;
  width: 10px;
  height: 10px;
  border-radius: 30px;
  background: rgba(0, 44, 82, 1);
  transform: translateX(-50%) translateY(-50%);
  transition: .4s top ease;
}

#menu_slider_circle::before {
  content: '';
  position: absolute;
  top: -8px;
  left: -8px;
  bottom: -8px;
  right: -8px;
  border-radius: 60px;
  background: rgba(0, 44, 82, .1);
}

JavaScript

// Jquery nav 
/*
 * jQuery One Page Nav Plugin
 * http://github.com/davist11/jQuery-One-Page-Nav
 *
 * Copyright (c) 2010 Trevor Davis (http://trevordavis.net)
 * Dual licensed under the MIT and GPL licenses.
 * Uses the same license as jQuery, see:
 * http://jquery.org/license
 *
 * @version 3.0.0
 *
 * Example usage:
 * $('#nav').onePageNav({
 *   currentClass: 'current',
 *   changeHash: false,
 *   scrollSpeed: 750
 * });
 */

;
(function($, window, document, undefined) {

  // our plugin constructor
  var OnePageNav = function(elem, options) {
    this.elem = elem;
    this.$elem = $(elem);
    this.options = options;
    this.metadata = this.$elem.data('plugin-options');
    this.$win = $(window);
    this.sections = {};
    this.didScroll = false;
    this.$doc = $(document);
    this.docHeight = this.$doc.height();
  };

  // the plugin prototype
  OnePageNav.prototype = {
    defaults: {
      navItems: 'a',
      currentClass: 'current',
      changeHash: false,
      easing: 'swing',
      filter: '',
      scrollSpeed: 750,
      scrollThreshold: 0.5,
      begin: false,
      end: false,
      scrollChange: false
    },

    init: function() {
      // Introduce defaults that can be extended either
      // globally or using an object literal.
      this.config = $.extend({}, this.defaults, this.options, this.metadata);

      this.$nav = this.$elem.find(this.config.navItems);

      //Filter any links out of the nav
      if (this.config.filter !== '') {
        this.$nav = this.$nav.filter(this.config.filter);
      }

      //Handle clicks on the nav
      this.$nav.on('click.onePageNav', $.proxy(this.handleClick, this));

      //Get the section positions
      this.getPositions();

      //Handle scroll changes
      this.bindInterval();

      //Update the positions on resize too
      this.$win.on('resize.onePageNav', $.proxy(this.getPositions, this));

      return this;
    },

    adjustNav: function(self, $parent) {
     ...