-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
61 lines (41 loc) · 1.66 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
/**
* Created by macbook on 20.11.17.
*/
document.addEventListener('DOMContentLoaded', function(){
let wrapper = document.getElementById('wrapper');
let topLayer = wrapper.querySelector('.top');
let handle = wrapper.querySelector('.handle');
let skew = 0;
let delta = 0;
if(wrapper.className.indexOf('skewed') != -1){
skew = 1000;
}
wrapper.addEventListener('mousemove', function(e){
delta = (e.clientX - window.innerWidth / 2) * 0.5;
handle.style.left = e.clientX + delta + 'px';
topLayer.style.width= e.clientX + skew + delta + 'px';
});
});
$(document).ready(function(){
$(window).scroll(function() {
var wScroll = $(this).scrollTop();
if(wScroll > $('.periscope').offset().top - $(window).height()){
$('.periscope').css({'background-position':'center '+ (wScroll - $('.periscope').offset().top) +'px'});
var opacity = (wScroll - $('.periscope').offset().top + 400) / (wScroll / 5);
$('.periscope__overlay').css({'opacity': opacity});
}
});
$('.views__button').on('click', function(e) {
var imageId = $(this).attr('id');
$(this).addClass('views__button_active')
.siblings().removeClass('views__button_active');
// $('.'+ imageId).show('slow')
// .siblings().hide('slow');
$('.'+ imageId).addClass('views__image_display')
.siblings().removeClass('views__image_display');
})
$('.main-navigation__item_basket, .periscope__button').on('click', function(e) {
e.preventDefault();
$('.basket-area').toggleClass('basket-area_display');
})
})