Skip to content

Commit 3e8862a

Browse files
committed
v1.3.0
1 parent 33977f4 commit 3e8862a

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "MenuSpy",
3-
"version": "1.0.1",
3+
"version": "1.3.0",
44
"homepage": "https://github.com/lcdsantos/menuspy",
55
"authors": [
66
"Leonardo Santos <leocs.1991@gmail.com>"

dist/menuspy.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! MenuSpy v1.2.1 (Nov 15 2017) - http://leocs.me/menuspy/ - Copyright (c) 2017 Leonardo Santos; MIT License */
1+
/*! MenuSpy v1.3.0 (Jan 31 2018) - http://leocs.me/menuspy/ - Copyright (c) 2018 Leonardo Santos; MIT License */
22
(function (global, factory) {
33
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
44
typeof define === 'function' && define.amd ? define(factory) :
@@ -83,7 +83,7 @@ var MenuSpy = function MenuSpy(element, options) {
8383
callback : null
8484
};
8585

86-
this.element = element;
86+
this.element = typeof element === 'string' ? document.querySelector(element) : element;
8787
this.options = utils.extend(defaults, options);
8888

8989
this.assignValues();
@@ -117,12 +117,12 @@ MenuSpy.prototype.cacheItems = function cacheItems () {
117117
this.scrollItems = this.menuItems.map(function (elm) {
118118
var target = elm.dataset.target ? document.querySelector(elm.dataset.target) : document.getElementById(elm.hash.slice(1));
119119
if (target) {
120-
var offset = utils.offset(target).top;
120+
var offset = Math.floor(utils.offset(target).top);
121121
return { elm: elm, target: target, offset: offset };
122122
}
123123
return false;
124124
});
125-
this.scrollItems = this.scrollItems.filter(Boolean);
125+
this.scrollItems = this.scrollItems.filter(Boolean).sort(function (a, b) { return a.offset - b.offset; });
126126
};
127127

128128
MenuSpy.prototype.tick = function tick () {

dist/menuspy.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)