- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
$(window).load(function () {
$(".sidebar-list").mCustomScrollbar({
// scrollButtons:{enable:true,scrollType:"stepped"},
keyboard: {
scrollType: "stepped"
},
mouseWheel: {
scrollAmount: 188
}, // theme:"rounded-dark",
scrollbarPosition: "inside",
autoExpandScrollbar: false,
snapAmount: 188,
snapOffset: 65
});
if ("onhashchange" in window && location.hash) {
match = location.hash.match(/^[?#!]*(.*)$/)[1];
scrollToPage(match);
};
if (!isMob.any() && isRoot) {
// return false;
var navM = $('.menu a');
var section = $.map($(".section"), function (e) {
var $e = $(e);
var pos = $e.position();
return {
top: pos.top - 75,
bottom: pos.top - 75 + $e.height(),
hash: '#!' + $e.attr('id'),
indx: $e.index()
};
});
//Checking scroll
var top = null;
var changed = false;
var currentHash = null;
$(window).scroll(function () {
var newTop = $(document).scrollTop();
changed = newTop != top;
if (changed) {
top = newTop;
// step();
}
});
function step() {
if (!changed) {
return setTimeout(step, 200);
}
var count = section.length;
var p;
while (p = section[--count]) {
if (p.top >= top || p.bottom <= top) {
continue;
}
if (currentHash == p.hash) {
break;
}
var scrollTop = $(document).scrollTop();
window.location.hash = currentHash = p.hash;
$(document).scrollTop(scrollTop);
}
setTimeout(step, 200);
}
setTimeout(step, 200);
}
});
Сей гениальный код должен управлять прокруткой и главным меню на сайте.
guest 11.12.2015 14:20 # −2
imihajlov 11.12.2015 16:27 # +2
HiNeX 14.12.2015 02:31 # +1