-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
157 lines (120 loc) · 4.62 KB
/
main.js
1
2
3
4
5
6
7
8
9
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*global $, jQuery, alert*/
$(document).ready(function() {
'use strict';
// ========================================================================= //
// //SMOOTH SCROLL
// ========================================================================= //
$(document).on("scroll", onScroll);
$('a[href^="#"]').on('click', function(e) {
e.preventDefault();
$(document).off("scroll");
$('a').each(function() {
$(this).removeClass('active');
if ($(window).width() < 768) {
$('.nav-menu').slideUp();
}
});
$(this).addClass('active');
var target = this.hash,
menu = target;
target = $(target);
$('html, body').stop().animate({
'scrollTop': target.offset().top - 80
}, 500, 'swing', function() {
window.location.hash = target.selector;
$(document).on("scroll", onScroll);
});
});
function onScroll(event) {
if ($('.home').length) {
var scrollPos = $(document).scrollTop();
$('nav ul li a').each(function() {
var currLink = $(this);
var refElement = $(currLink.attr("href"));
});
}
}
// ========================================================================= //
// //NAVBAR SHOW - HIDE
// ========================================================================= //
$(window).scroll(function() {
var scroll = $(window).scrollTop();
if (scroll > 200 ) {
$("#main-nav, #main-nav-subpage").slideDown(700);
$("#main-nav-subpage").removeClass('subpage-nav');
} else {
$("#main-nav").slideUp(700);
$("#main-nav-subpage").hide();
$("#main-nav-subpage").addClass('subpage-nav');
}
});
// ========================================================================= //
// // RESPONSIVE MENU
// ========================================================================= //
$('.responsive').on('click', function(e) {
$('.nav-menu').slideToggle();
});
// ========================================================================= //
// Typed Js
// ========================================================================= //
var typed = $(".typed");
$(function() {
typed.typed({
strings: ["Ahmed BaFadhl.", "Designer.", "Artist.", "Freelancer.", "Photographer."],
typeSpeed: 100,
loop: true,
});
});
// ========================================================================= //
// Owl Carousel Services
// ========================================================================= //
$('.services-carousel').owlCarousel({
autoplay: true,
loop: true,
margin: 20,
dots: true,
nav: false,
responsiveClass: true,
responsive: { 0: { items: 1 }, 768: { items: 2 }, 900: { items: 4 } }
});
// ========================================================================= //
// Porfolio isotope and filter
// ========================================================================= //
var portfolioIsotope = $('.portfolio-container').isotope({
itemSelector: '.portfolio-thumbnail',
layoutMode: 'fitRows'
});
$('#portfolio-flters li').on( 'click', function() {
$("#portfolio-flters li").removeClass('filter-active');
$(this).addClass('filter-active');
portfolioIsotope.isotope({ filter: $(this).data('filter') });
});
// ========================================================================= //
// magnificPopup
// ========================================================================= //
var magnifPopup = function() {
$('.popup-img').magnificPopup({
type: 'image',
removalDelay: 300,
mainClass: 'mfp-with-zoom',
gallery: {
enabled: true
},
zoom: {
enabled: true, // By default it's false, so don't forget to enable it
duration: 300, // duration of the effect, in milliseconds
easing: 'ease-in-out', // CSS transition easing function
// The "opener" function should return the element from which popup will be zoomed in
// and to which popup will be scaled down
// By defailt it looks for an image tag:
opener: function(openerElement) {
// openerElement is the element on which popup was initialized, in this case its <a> tag
// you don't need to add "opener" option if this code matches your needs, it's defailt one.
return openerElement.is('img') ? openerElement : openerElement.find('img');
}
}
});
};
// Call the functions
magnifPopup();
});