Skip to content

Instantly share code, notes, and snippets.

@amitrahav
Created October 10, 2019 07:38
Show Gist options
  • Save amitrahav/47482e834c2d03a3ca3444114909cbc6 to your computer and use it in GitHub Desktop.
Save amitrahav/47482e834c2d03a3ca3444114909cbc6 to your computer and use it in GitHub Desktop.
(function($) {
// define easeInOutQuint
$.easing.jswing = $.easing.swing;
$.extend($.easing, {
easeInOutQuint: function(x, t, b, c, d) {
if ((t /= d / 2) < 1) return (c / 2) * t * t * t * t * t + b;
return (c / 2) * ((t -= 2) * t * t * t * t + 2) + b;
}
});
// wow
new WOW().init();
// loader
function showLoader() {
$("#loader-wrapper").show();
setTimeout(function() {
$("#loader-wrapper").addClass("show");
}, 50);
}
function hideLoader() {
$("#loader-wrapper").removeClass("show");
setTimeout(function() {
$("#loader-wrapper").hide();
}, 300);
}
function openPopup(id) {
var scrollLocation = $(window).scrollTop();
$(".popup#popup-" + id).addClass("show");
location.hash = id;
$(window).scrollTop(scrollLocation);
}
function openPopside(id) {
var scrollLocation = $(window).scrollTop();
$(".popside#popside-" + id).addClass("show");
location.hash = id;
$(window).scrollTop(scrollLocation);
}
function closePopup(id) {
var scrollLocation = $(window).scrollTop();
if (id) {
$(".popup#popup-" + id).removeClass("show");
location.hash = location.hash.replace(id, "");
} else {
$(".popup").removeClass("show");
location.hash = undefined;
}
if (location.hash.length == 0) {
history.replaceState(null, null, " ");
}
$(window).scrollTop(scrollLocation);
}
function checkHashPopups() {
var id = location.hash.replace("#", "");
if ($("#popup-" + id).length) {
openPopup(id);
} else {
openPopside(id);
}
}
checkHashPopups();
$(".menu-button-wrapper").on("click", function() {
$(this).toggleClass("open");
$(".main-menu").toggleClass("open");
});
$(".open-popup").on("click", function() {
openPopup($(this).data("target"));
});
$(".close-popup").on("click", function() {
closePopup($(this).data("target"));
});
// SVG animations
$("[data-src$='svg']").each(function(idx, el) {
var id = "vivus-" + idx;
var src = $(el).attr("data-src");
$(el).attr("id", id);
new Vivus(id, {
file: src
});
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment