質問編集履歴
1
現状のソースコードの追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -15,4 +15,57 @@
|
|
15
15
|
しかしサイトと同じようなきれいなアニメーションを実装することはできず、悩んでいます。
|
16
16
|
|
17
17
|
なるべく具体的に教えていただけると幸いです。
|
18
|
-
よろしくお願いいたします。
|
18
|
+
よろしくお願いいたします。
|
19
|
+
|
20
|
+
### 該当のソースコード
|
21
|
+
|
22
|
+
```HTML
|
23
|
+
<div class="mask">
|
24
|
+
<figure><img src="./img/img_01.png"></figure>
|
25
|
+
</div>
|
26
|
+
```
|
27
|
+
|
28
|
+
```SCSS
|
29
|
+
.mask {
|
30
|
+
position: relative;
|
31
|
+
width: 80%;
|
32
|
+
margin: 30px auto 30px;
|
33
|
+
.mask-bg {
|
34
|
+
position: absolute;
|
35
|
+
top: 0;
|
36
|
+
right: 0;
|
37
|
+
width: 100%;
|
38
|
+
height: 100%;
|
39
|
+
z-index: 2;
|
40
|
+
background-color: #10404c;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
```
|
44
|
+
|
45
|
+
|
46
|
+
```Javascript
|
47
|
+
//要素の取得とスピードの設定
|
48
|
+
var box = $('.mask'),
|
49
|
+
speed = 700;
|
50
|
+
|
51
|
+
box.each(function(){
|
52
|
+
$(this).append('<div class="mask-bg"></div>')
|
53
|
+
var maskbg = $(this).find($('.mask-bg')),
|
54
|
+
image = $(this).find('img');
|
55
|
+
var counter = 0;
|
56
|
+
|
57
|
+
image.css('opacity','0');
|
58
|
+
maskbg.css('width','0%');
|
59
|
+
//inviewを使って背景色が画面に現れたら処理をする
|
60
|
+
maskbg.on('inview', function(){
|
61
|
+
if(counter == 0){
|
62
|
+
$(this).delay(200).animate({'width':'100%'},speed,function(){
|
63
|
+
image.css('opacity','1');
|
64
|
+
$(this).css({'left':'0' , 'right':'auto'});
|
65
|
+
$(this).animate({'width':'0%'},speed);
|
66
|
+
})
|
67
|
+
counter = 1;
|
68
|
+
}
|
69
|
+
});
|
70
|
+
});
|
71
|
+
```
|