質問編集履歴

1

現状のソースコードの追記

2021/02/01 08:32

投稿

onakapecomaru
onakapecomaru

スコア10

test CHANGED
File without changes
test CHANGED
@@ -33,3 +33,109 @@
33
33
  なるべく具体的に教えていただけると幸いです。
34
34
 
35
35
  よろしくお願いいたします。
36
+
37
+
38
+
39
+ ### 該当のソースコード
40
+
41
+
42
+
43
+ ```HTML
44
+
45
+ <div class="mask">
46
+
47
+ <figure><img src="./img/img_01.png"></figure>
48
+
49
+ </div>
50
+
51
+ ```
52
+
53
+
54
+
55
+ ```SCSS
56
+
57
+ .mask {
58
+
59
+ position: relative;
60
+
61
+ width: 80%;
62
+
63
+ margin: 30px auto 30px;
64
+
65
+ .mask-bg {
66
+
67
+ position: absolute;
68
+
69
+ top: 0;
70
+
71
+ right: 0;
72
+
73
+ width: 100%;
74
+
75
+ height: 100%;
76
+
77
+ z-index: 2;
78
+
79
+ background-color: #10404c;
80
+
81
+ }
82
+
83
+ }
84
+
85
+ ```
86
+
87
+
88
+
89
+
90
+
91
+ ```Javascript
92
+
93
+ //要素の取得とスピードの設定
94
+
95
+ var box = $('.mask'),
96
+
97
+ speed = 700;
98
+
99
+
100
+
101
+ box.each(function(){
102
+
103
+ $(this).append('<div class="mask-bg"></div>')
104
+
105
+ var maskbg = $(this).find($('.mask-bg')),
106
+
107
+ image = $(this).find('img');
108
+
109
+ var counter = 0;
110
+
111
+
112
+
113
+ image.css('opacity','0');
114
+
115
+ maskbg.css('width','0%');
116
+
117
+ //inviewを使って背景色が画面に現れたら処理をする
118
+
119
+ maskbg.on('inview', function(){
120
+
121
+ if(counter == 0){
122
+
123
+      $(this).delay(200).animate({'width':'100%'},speed,function(){
124
+
125
+ image.css('opacity','1');
126
+
127
+ $(this).css({'left':'0' , 'right':'auto'});
128
+
129
+ $(this).animate({'width':'0%'},speed);
130
+
131
+ })
132
+
133
+ counter = 1;
134
+
135
+ }
136
+
137
+ });
138
+
139
+ });
140
+
141
+ ```