|
Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /proc/self/root/var/www/blue-sky.co.id/public_html/themes/1/sticky_navbar/ |
Upload File : |
var mainNavLinks = document.querySelectorAll(
".nav-job-vacancy .ul-job-vacancy li a"
)
var mainSections = document.querySelectorAll(
".parent-job-vacancy .item-job-vacancy"
)
if (mainNavLinks.length > 0) {
// alert(window.location.hash);
var lastId
var cur = []
// This should probably be throttled.
// Especially because it triggers during smooth scrolling.
// https://lodash.com/docs/4.17.10#throttle
// You could do like...
// window.addEventListener("scroll", () => {
// _.throttle(doThatStuff, 100);
// });
// Only not doing it here to keep this Pen dependency-free.
Array.from(mainNavLinks).forEach(function (element) {
element.addEventListener("click", function (eve) {
eve.preventDefault()
// var t_top = this.getBoundingClientRect().top;
// var t_top = this.offsetTop;
var ele_target = document.querySelector(eve.originalTarget.hash)
// var t_top = parseInt(ele_target.scrollTop);
// console.log(ele_target);
// console.log(eve.originalTarget.hash);
// var t_top = document.querySelector(eve.hash).offsetTop;
// ele_target.scrollIntoView();
// window.scroll({
// top: t_top,
// // left: 100,
// behavior: 'smooth'
// });
var t_top = parseInt(findPos(ele_target) - 10)
window.scroll(0, t_top)
Array.from(mainNavLinks).forEach(function (ele2) {
ele2.classList.remove("current")
})
eve.originalTarget.classList.add("current")
})
})
// window.addEventListener("scroll", event => {
// var element = document.getElementById('parent-job-vacancy');
// // var element = docuement.getElementById('flux');
// if (element.offsetHeight + element.scrollTop === element.scrollHeight) {
// // element is at the end of its scroll, load more content
// // console.log(element.scrollHeight);
// }
// });
// window.addEventListener("scroll", event => {
// let fromTop = window.scrollY;
// mainNavLinks.forEach(link => {
// let section = document.querySelector(link.hash);
// if (
// section.offsetTop <= fromTop &&
// section.offsetTop + section.offsetHeight > fromTop
// ) {
// link.classList.add("current");
// } else {
// link.classList.remove("current");
// }
// });
// });
var sticky = $("nav#nav-job-vacancy"),
stickyClone,
stickyTop = sticky.offset().top,
scrollTop,
scrolled = false,
$window = $(window)
/* Bind the scroll Event */
$window.on("scroll", function (e) {
scrollTop = $window.scrollTop()
if (scrollTop >= stickyTop && !stickyClone) {
/* Attach a clone to replace the "missing" body height */
stickyClone = sticky.clone().prop("id", sticky.prop("id") + "-clone")
stickyClone = stickyClone.insertBefore(sticky)
sticky.addClass("fixed")
} else if (scrollTop < stickyTop && stickyClone) {
/* Since sticky is in the viewport again, we can remove the clone and the class */
stickyClone.remove()
stickyClone = null
sticky.removeClass("fixed")
}
})
}
function findPos(obj) {
var curtop = 0
if (obj.offsetParent) {
do {
curtop += obj.offsetTop
} while ((obj = obj.offsetParent))
return [curtop]
}
}