PageSourceSearch

https://bbj-movie.com/static/js/NavScroll.js

js bbj-movie.com collected 2026-10-04 12:02:41 UTC 4,386 bytes, 136 lines download raw bytes

1/*!
2 * NavScroll.js
3 * Version: 1.2.0
4 * Author: Jeroen Hammann
5 *
6 * Copyright (c) 2014 Jeroen Hammann
7 * Released under the MIT license
8*/
9
10;(function ($, window, document, undefined) {
11  'use strict';
12
13  var pluginName = 'navScroll',
14      defaults = {
15        // The time it takes to scroll to the element (set this to 0 so it obviously won't show an animation).
16        scrollTime: 500,
17        // The class of the items which invokes the scroll animation. All anchor tags inside the element are clickable when the value is empty.
18        navItemClassName: '',
19        // Set the height of the navigation (to use as offset). 'auto' let's the plugin determine the height automatically, a number determines the height in px.
20        navHeight: 'auto',
21        // If your navigation hides and is used as a dropdown on small screens setting this to true hides the dropdown after a click.
22        mobileDropdown: false,
23        // Additionaly you can insert the mobile nav's classname here, when left empty the plugin searches for a <ul> in the same parent element.
24        mobileDropdownClassName: '',
25        // The window width, which functions as a breakpoint between desktop and mobile.
26        mobileBreakpoint: 1024,
27        // Set to 'true' if you want to enable scrollspy.
28        scrollSpy: false
29      };
30
31  function NavScroll(element, options) {
32    this.element = element;
33    this.options = $.extend({}, defaults, options);
34
35    this._defaults = defaults;
36    this._name = pluginName;
37
38    this.init();
39  }
40
41  NavScroll.prototype = {
42    init: function() {
43      var self, options, element, navItem, navOffset, scrollTime;
44      self = this;
45      options = self.options;
46      element = self.element;
47
48      if (options.navItemClassName === '') {
49        navItem = $(element).find('a');
50      } else {
51        navItem = $(element).find('.' + options.navItemClassName);
52      }
53
54      if (options.navHeight === 'auto') {
55        navOffset = $(element).height();
56      } else if (isNaN(options.navHeight)) {
57        throw new Error ('\'navHeight\' only accepts \'auto\' or a number as value.');
58      } else {
59        navOffset = options.navHeight;
60      }
61
62      navItem.on('click', function(e){
63        var url, parts, target, targetOffset, targetTop;
64
65        url = this.href;
66        parts = url.split('#');
67        target = parts[1];
68
69        if (target !== undefined) {
70          e.preventDefault();
71          targetOffset = $('#' + target).offset();
72          targetTop = targetOffset.top;
73        }
74
75        if ($(this).data('scrolltime') !== undefined) {
76          scrollTime = $(this).data('scrolltime');
77        } else {
78          scrollTime = options.scrollTime;
79        }
80
81        if (options.mobileDropdown && $(window).width() >= 0 && $(window).width() <= options.mobileBreakpoint) {
82          if (options.mobileDropdownClassName === '') {
83            $(element).find('ul').slideUp('fast');
84          } else {
85            $('.' + options.mobileDropdownClassName).slideUp('fast');
86          }
87        }
88
89        $('html, body').stop().animate({
90          scrollTop: targetTop - navOffset
91        }, scrollTime);
92      });
93
94      if (options.scrollSpy) {
95        var scrollItems;
96        scrollItems = [];
97
98        navItem.each(function() {
99          var scrollItemId = $(this).attr('href');
100          scrollItems.push($(scrollItemId));
101        });
102
103        $(window).on('scroll', function () {
104          self.scrollspy(navItem, scrollItems);
105        });
106        self.scrollspy(navItem, scrollItems);
107      }
108    },
109
110    scrollspy: function(navItem, scrollItems) {
111      var scrollPos, changeBounds, i, l;
112      scrollPos = (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;
113//  changeBounds = window.innerHeight / 2 || document.documentElement.clientHeight / 2;
114      l = navItem.length;
115
116      for (i = 0; l > i; i++) {
117        var item = scrollItems[i];
118        if (scrollPos > (item.offset().top-110)) {
119          navItem.removeClass('active');
120          $(navItem[i]).addClass('active');
121        }
122      }
123    }
124  };
125
126  $.fn[pluginName] = function (options) {
127    return this.each(function () {
128      if (!$.data(this, 'plugin_' + pluginName)) {
129        $.data(this, 'plugin_' + pluginName,
130        new NavScroll(this, options));
131      }
132    });
133  };
134
135})(jQuery, window, document);
136/* cluster_id: 177741339945 */

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.