@@ -12,11 +12,11 @@ document.addEventListener("DOMContentLoaded", function(event) {
12
12
document . querySelector ( 'header h1' ) . innerHTML = randomize ;
13
13
} ) ;
14
14
15
- document . querySelector ( " .button_icon" ) . addEventListener ( " click" , function ( ) {
16
- document . querySelector ( " header" ) . classList . toggle ( " open_icon_menu" ) ;
15
+ document . querySelector ( ' .button_icon' ) . addEventListener ( ' click' , function ( ) {
16
+ document . querySelector ( ' header' ) . classList . toggle ( ' open_icon_menu' ) ;
17
17
} )
18
18
19
- var gallery = document . querySelectorAll ( " .photo" ) ;
19
+ var gallery = document . querySelectorAll ( ' .photo' ) ;
20
20
21
21
for ( var i = 0 ; i < gallery . length ; i ++ ) {
22
22
( function loop ( index ) {
@@ -28,17 +28,24 @@ for(var i = 0; i < gallery.length; i++) {
28
28
29
29
$ ( function ( ) {
30
30
$ ( '.fclick' ) . on ( 'click' , darkness ) ;
31
- $ ( 'body' ) . mousemove ( light_move ) ;
32
- document . querySelector ( " body" ) . addEventListener ( " touchmove" , light_move ) ;
31
+ $ ( 'body' ) . on ( 'mousemove' , light_move ) ;
32
+ $ ( ' body' ) . on ( ' touchmove' , light_move_mobile ) ;
33
33
} )
34
34
35
35
function light_move ( e ) {
36
36
if ( $ ( '.fclick' ) . text ( ) == "Включить свет" ) {
37
- obj = document . getElementById ( " overlay" ) ;
37
+ obj = document . getElementById ( ' overlay' ) ;
38
38
obj . style . top = e . clientY / document . documentElement . clientHeight * 100 - 150 + "vh" ;
39
39
obj . style . left = 1 * e . clientX / document . documentElement . clientWidth * 100 - 150 + "vw" ;
40
40
}
41
41
}
42
+ function light_move_mobile ( e ) {
43
+ if ( $ ( '.fclick' ) . text ( ) == "Включить свет" ) {
44
+ obj = document . getElementById ( 'overlay' ) ;
45
+ obj . style . top = e . targetTouches [ 0 ] . clientY / document . documentElement . clientHeight * 100 - 150 + "vh" ;
46
+ obj . style . left = 1 * e . targetTouches [ 0 ] . clientX / document . documentElement . clientWidth * 100 - 150 + "vw" ;
47
+ }
48
+ }
42
49
function darkness ( ) {
43
50
if ( $ ( '.fclick' ) . text ( ) == "Выключить свет" ) {
44
51
$ ( 'body' ) . append ( "<div id='overlay' class='overlay'></div>" ) ;
@@ -48,7 +55,7 @@ function darkness(){
48
55
'top' : '-100vh' ,
49
56
'left' : '-100vw' ,
50
57
'background-color' : 'black' ,
51
- 'background' : 'radial-gradient(transparent,rgba(0,0,0,0.6),rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6))' ,
58
+ 'background' : 'radial-gradient(circle, transparent,rgba(0,0,0,0.6),rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6), rgba(0,0,0,0.6))' ,
52
59
'width' : '300vw' ,
53
60
'height' : '300vh' ,
54
61
'z-index' : 5000 ,
0 commit comments