// Sticky Header
// grab an element
var header = document.getElementById("masthead");
// construct an instance of Headroom, passing the element
var headroom = new Headroom(header, {
tolerance: {
down : 10,
up : 20
},
offset : 205
});
// initialise
headroom.init();
( function( $ ) {
//Checks if current locale is RTL (Right To Left script) and sets the carousel accordingly.
if(is_rtl != true){
is_rtl = false;
}
// Counters Section
$('.counters').on('inview', function(event, isInView) {
if (isInView) {
setTimeout(function(){
if( php_vars.odometer1 != ""){
$('.odometer1').html(php_vars.odometer1);
}
if( php_vars.odometer2 != ""){
$('.odometer2').html(php_vars.odometer2);
}
if( php_vars.odometer3 != ""){
$('.odometer3').html(php_vars.odometer3);
}
if( php_vars.odometer4 != ""){
$('.odometer4').html(php_vars.odometer4);
}
}, 1000);
}
});
// Animate any elements with animate settings
$(".animated").on("inview", function(isVisible) {
// Event is triggered once the element becomes visible in the browser's viewport, and once when it becomes invisible
if (isVisible) {
$(this).css('visibility','visible');
$(this).addClass($(this).data('fx'));
}
});
$('.equal-heights').equalHeights();
// Latest Posts Carousel
$(".owl-carousel").owlCarousel({
loop:true,
nav:true,
lazyLoad: true,
rtl:is_rtl,
navText: [
'',
''],
responsiveClass:true,
responsive:{
0:{
items:1
},
600:{
items:2
},
1000:{
items:3
}
}
});
// Testimonial Carousel
$("#client-feedbacks").owlCarousel({
loop:true,
items:2,
nav:true,
lazyLoad: true,
rtl:is_rtl,
responsive:{
0:{
items:1
},
800:{
items:2
}
},
navText: [
'',
'']
});
console.log(is_rtl);
// TEAM Carousel
$(".team-members").owlCarousel({
lazyLoad: true,
responsiveClass:true,
rtl:is_rtl,
responsive:{
0:{
items:2
},
600:{
items:3
},
1000:{
items:4
}
}
});
$owlCarouselTeam = $(".team-members");
var is_mobile = true;
if( $('.menu-toggle').css('display')=='none') {
is_mobile = false;
}
$(window).resize(function() {
if( $('.menu-toggle').css('display')=='none') {
is_mobile = false;
}
});
// now i can use is_mobile to run javascript conditionally
if (is_mobile == false) {
//Conditional script here
$owlCarouselTeam.imagesLoaded(function() {
$owlCarouselTeam.find(".team-member").each(function() {
var b = $(this).find(".profile-pic").width();
var c = $(this).find(".profile-pic").height();
$(this).find(".member-details").css({
top: c + "px",
width: b + "px",
height: c + "px"
});
});
});
}
// Smooth Scrolling
$(function() {
$('a[href*="#"]:not([href="#"])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html, body').animate({
scrollTop: target.offset().top
}, 800);
return false;
}
}
});
});
/*
* /////////////////////////////
* STRENGTHS SECTION
* /////////////////////////////
*/
var count = $('.progress-wrap').length;
$('.skills').on('inview', function(event, isInView) {
if (isInView) {
// element is now visible in the viewport
setTimeout(function(){
$('.progress-wrap').each(function(){
percent = $(this);
bar = $(this).children('.progress-bar');
moveProgressBar(percent, bar);
});
// on browser resize...
$(window).resize(function() {
$('.progress-wrap').each(function(){
percent = $(this);
bar = $(this).children('.progress-bar');
moveProgressBar(percent, bar);
});
});
// STRENGTH PROGRESS
function moveProgressBar(percent, bar) {
console.log("moveProgressBar");
var getPercent = (percent.data('progress-percent') / 100);
var getProgressWrapWidth = percent.width();
var progressTotal = getPercent * getProgressWrapWidth;
var animationLength = 1000;
// on page load, animate percentage bar to data percentage length
// .stop() used to prevent animation queueing
bar.stop().animate({
left: progressTotal
}, animationLength);
}
}, 400 * count + 400);
}
});
$(window).trigger('resize').trigger('scroll');
} )( jQuery );