<commit_before>/**
 *  client
 **/

/**
 *  client.common
 **/

/**
 *  client.common.floatbar
 **/


'use strict';


/*global N, window*/


var _ = require('lodash');
var $ = window.jQuery;


N.wire.on('navigate.done', function () {
  // fix sub nav on scroll
  var $win = $(window), $bar = $('#floatbar');

  // remove previous floatbar handlers (if any)
  $win.off('.floatbar');

  if (!$bar.length) {
    // do nothing if there's no floatbar
    return;
  }

  var navTop = $bar.offset().top, isFixed = false;

  function updateFloatbarState() {
    var scrollTop = $win.scrollTop();

    if (scrollTop >= navTop && !isFixed) {
      isFixed = true;
      $bar.addClass('floatbar-fixed');
      return;
    }

    if (scrollTop <= navTop && isFixed) {
      isFixed = false;
      $bar.removeClass('floatbar-fixed');
      return;
    }
  }

  updateFloatbarState();

  $win.on('scroll.floatbar', _.throttle(updateFloatbarState, 100));
});<commit_msg>Style changes in the floatbar handler.<commit_after>/**
 *  client
 **/

/**
 *  client.common
 **/

/**
 *  client.common.floatbar
 **/


'use strict';


/*global N, window*/


var _ = require('lodash');
var $ = window.jQuery;


N.wire.on('navigate.done', function () {
  var $window   = $(window)
    , $floatbar = $('#floatbar')
    , isFixed   = false
    , navTop;

  // Remove previous floatbar handlers if any.
  $window.off('.floatbar');

  if (0 === $floatbar.length) {
    // Do nothing if there's no floatbar.
    return;
  }

  navTop  = $floatbar.offset().top;
  isFixed = false;

  function updateFloatbarState() {
    var scrollTop = $window.scrollTop();

    if (scrollTop >= navTop && !isFixed) {
      isFixed = true;
      $floatbar.addClass('floatbar-fixed');

    } else if (scrollTop <= navTop && isFixed) {
      isFixed = false;
      $floatbar.removeClass('floatbar-fixed');
    }
  }

  updateFloatbarState();

  $window.on('scroll.floatbar', _.throttle(updateFloatbarState, 100));
});
{'fraction_non_alphanumeric': 0.17599186164801628, 'fraction_numerical': 0.003560528992878942, 'mean_word_length': 2.804642166344294, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3678815', 'n_tokens_mistral': 694, 'n_tokens_neox': 660, 'n_words': 144}