回答編集履歴
11
マークダウン修正
answer
CHANGED
@@ -146,7 +146,7 @@
|
|
146
146
|
$(".main .a").animate({top: 100, marginLeft: 60, bottom: 0}, 800, method1, function () {
|
147
147
|
$(this).animate({marginLeft: 60}, 1000, method1, function () {
|
148
148
|
$(this).transition({scaleX: 1.5, scaleY: 1.5, duration: 1000}, function () {
|
149
|
-
|
149
|
+
$(this).transition({scaleX: 1.0, scaleY: 1.0, duration: 1000});
|
150
150
|
});
|
151
151
|
});
|
152
152
|
});
|
10
修正
answer
CHANGED
@@ -146,10 +146,28 @@
|
|
146
146
|
$(".main .a").animate({top: 100, marginLeft: 60, bottom: 0}, 800, method1, function () {
|
147
147
|
$(this).animate({marginLeft: 60}, 1000, method1, function () {
|
148
148
|
$(this).transition({scaleX: 1.5, scaleY: 1.5, duration: 1000}, function () {
|
149
|
-
|
149
|
+
``` $(this).transition({scaleX: 1.0, scaleY: 1.0, duration: 1000});
|
150
150
|
});
|
151
151
|
});
|
152
152
|
});
|
153
153
|
});
|
154
154
|
});
|
155
|
+
```
|
156
|
+
|
157
|
+
###間違いがあったので修正
|
158
|
+
```javascript
|
159
|
+
<script type="text/javascript">
|
160
|
+
$(function () {
|
161
|
+
var method1 = "easeOutElastic";
|
162
|
+
$(".main .a").fadeIn(2000, function () {
|
163
|
+
$(this).animate({top: 100, marginLeft: 60, bottom: 0}, 800, method1, function () {
|
164
|
+
$(this).animate({marginLeft: 60}, 1000, method1, function () {
|
165
|
+
$(this).transition({scaleX: 1.5, scaleY: 1.5, duration: 1000}, function () {
|
166
|
+
$(this).transition({scaleX: 1.0, scaleY: 1.0, duration: 1000});
|
167
|
+
});
|
168
|
+
});
|
169
|
+
});
|
170
|
+
});
|
171
|
+
});
|
172
|
+
</script>
|
155
173
|
```
|
9
追記
answer
CHANGED
@@ -134,4 +134,22 @@
|
|
134
134
|
</script>
|
135
135
|
</body>
|
136
136
|
</html>
|
137
|
+
```
|
138
|
+
|
139
|
+
動きを見やすくするため、duration を 1000 にしてみた
|
140
|
+
|
141
|
+
```javascript
|
142
|
+
|
143
|
+
$(function () {
|
144
|
+
var method1 = "easeOutElastic";
|
145
|
+
$(".main .a").fadeIn(2000, function () {
|
146
|
+
$(".main .a").animate({top: 100, marginLeft: 60, bottom: 0}, 800, method1, function () {
|
147
|
+
$(this).animate({marginLeft: 60}, 1000, method1, function () {
|
148
|
+
$(this).transition({scaleX: 1.5, scaleY: 1.5, duration: 1000}, function () {
|
149
|
+
$(this).transition({scaleX: 1.0, scaleY: 1.0, duration: 1000});
|
150
|
+
});
|
151
|
+
});
|
152
|
+
});
|
153
|
+
});
|
154
|
+
});
|
137
155
|
```
|
8
追記
answer
CHANGED
@@ -85,4 +85,53 @@
|
|
85
85
|
以下のどちらも「transition」メソッドを使うようなので…
|
86
86
|
|
87
87
|
[jquery.transition.js](https://github.com/louisremi/jquery.transition.js/blob/master/jquery.transition.js)
|
88
|
-
[jquery.transit](https://github.com/rstacruz/jquery.transit)
|
88
|
+
[jquery.transit](https://github.com/rstacruz/jquery.transit)
|
89
|
+
|
90
|
+
|
91
|
+
###とどのつまりはこういう風にしたいのではと推測して書いてみました
|
92
|
+
|
93
|
+
そのままコピペで動くと思います。当方、Mac のため IE での動作検証はできません、あしからず…
|
94
|
+
http でアクセスする場合は https を http に変更してください。
|
95
|
+
|
96
|
+
jquery.transition.js にはどうも transition メソッドないようなので、jquery.transit を使っております。
|
97
|
+
|
98
|
+
```html
|
99
|
+
<!DOCTYPE HTML>
|
100
|
+
<html lang="ja-JP">
|
101
|
+
<head>
|
102
|
+
<meta charset="UTF-8">
|
103
|
+
<title></title>
|
104
|
+
<style type="text/css">
|
105
|
+
.a {
|
106
|
+
position: absolute;
|
107
|
+
display: none;
|
108
|
+
top: -220px;
|
109
|
+
}
|
110
|
+
</style>
|
111
|
+
</head>
|
112
|
+
<body>
|
113
|
+
|
114
|
+
<div class="main">
|
115
|
+
<img class="a" src="https://dummyimage.com/100x100/000/fff" alt="ロゴ" />
|
116
|
+
</div>
|
117
|
+
|
118
|
+
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
|
119
|
+
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
|
120
|
+
<script type="text/javascript" src="https://raw.githubusercontent.com/rstacruz/jquery.transit/master/jquery.transit.js"></script>
|
121
|
+
<script type="text/javascript">
|
122
|
+
$(function () {
|
123
|
+
var method1 = "easeOutElastic";
|
124
|
+
$(".main .a").fadeIn(2000, function () {
|
125
|
+
$(".main .a").animate({top: 100, marginLeft: 60, bottom: 0}, 800, method1, function () {
|
126
|
+
$(this).animate({marginLeft: 60}, 100, method1, function () {
|
127
|
+
$(this).transition({scaleX: 1.5, scaleY: 1.5, duration: 100}, function () {
|
128
|
+
$(this).transition({scaleX: 1.0, scaleY: 1.0, duration: 100});
|
129
|
+
});
|
130
|
+
});
|
131
|
+
});
|
132
|
+
});
|
133
|
+
});
|
134
|
+
</script>
|
135
|
+
</body>
|
136
|
+
</html>
|
137
|
+
```
|
7
追記
answer
CHANGED
@@ -57,4 +57,32 @@
|
|
57
57
|
|
58
58
|
[F12 開発者ツールを使用して JavaScript エラーをデバッグする](https://msdn.microsoft.com/ja-jp/library/gg699336%28v=vs.85%29.aspx)
|
59
59
|
|
60
|
-
ブラウザの動き自体からは判断できない潜在的な不具合も事前に防止することができます。
|
60
|
+
ブラウザの動き自体からは判断できない潜在的な不具合も事前に防止することができます。
|
61
|
+
|
62
|
+
---
|
63
|
+
|
64
|
+
```javascript
|
65
|
+
$(".main .a").transition({scaleX: 1.5, scaleX:1.5, duration: 100}, {scaleY: 1.5, scaleY:1.5, duration: 100});
|
66
|
+
$(".main .a").transition({scaleY: 1.5, scaleY:1.5, duration: 100}, {scaleX: 1.5, scaleX:1.5, duration: 100});
|
67
|
+
$(".main .a").transition({scaleY: 1.0, scaleY:1.0, duration: 100}, {scaleX: 1.0, scaleX:1.0, duration: 100});
|
68
|
+
$(".main .a").transition({scaleX: 1.0, scaleX:1.0, duration: 100}, {scaleY: 1.0, scaleY:1.0, duration: 100});
|
69
|
+
```
|
70
|
+
|
71
|
+
この部分、**同じプロパティが二重に設定さてれいる**のは正しい使い方なのだろうか。
|
72
|
+
|
73
|
+
```javascript
|
74
|
+
$(".main .a").transition({scaleX:1.5, duration: 100}, {scaleY:1.5, duration: 100});
|
75
|
+
$(".main .a").transition({scaleY:1.5, duration: 100}, {scaleX:1.5, duration: 100});
|
76
|
+
$(".main .a").transition({scaleY:1.0, duration: 100}, {scaleX:1.0, duration: 100});
|
77
|
+
$(".main .a").transition({scaleX:1.0, duration: 100}, {scaleY:1.0, duration: 100});
|
78
|
+
```
|
79
|
+
|
80
|
+
こうではないだろうか
|
81
|
+
|
82
|
+
あと、この4行はほぼ同時に実行されるので、一つ目の処理の終了を待たずに次が実行されるのでは?
|
83
|
+
現時点で、何のプラグインを使っているのかわからないので推測です。コールバックが用意されているのであればそれを使うか、メソッドチェーンで実装が正解か。これも推測。
|
84
|
+
|
85
|
+
以下のどちらも「transition」メソッドを使うようなので…
|
86
|
+
|
87
|
+
[jquery.transition.js](https://github.com/louisremi/jquery.transition.js/blob/master/jquery.transition.js)
|
88
|
+
[jquery.transit](https://github.com/rstacruz/jquery.transit)
|
6
tuiki
answer
CHANGED
File without changes
|
5
追記
answer
CHANGED
@@ -50,3 +50,11 @@
|
|
50
50
|
決められたルールに則って書かないと、動くわけがありません。
|
51
51
|
|
52
52
|
**「自分の書いたすべてのソースコードについて説明できるように」**しましょう。
|
53
|
+
|
54
|
+
###JavaScript のデバッグについて
|
55
|
+
|
56
|
+
闇雲にソースをいじるのは、デバッグの方法としてナンセンスですし、何より時間の無駄ですから、「開発ツール」を使いこなしてください。
|
57
|
+
|
58
|
+
[F12 開発者ツールを使用して JavaScript エラーをデバッグする](https://msdn.microsoft.com/ja-jp/library/gg699336%28v=vs.85%29.aspx)
|
59
|
+
|
60
|
+
ブラウザの動き自体からは判断できない潜在的な不具合も事前に防止することができます。
|
4
追記
answer
CHANGED
@@ -44,4 +44,9 @@
|
|
44
44
|
// $(".main .a").transition({scaleX: 1.0, scaleX:1.0, duration: 100}, {scaleY: 1.0, scaleY:1.0, duration: 100});
|
45
45
|
});
|
46
46
|
</script>
|
47
|
-
```
|
47
|
+
```
|
48
|
+
|
49
|
+
率直な感想を言うと…ネットで寄せ集めたコードを秩序なくただ書いてみただけという印象です。
|
50
|
+
決められたルールに則って書かないと、動くわけがありません。
|
51
|
+
|
52
|
+
**「自分の書いたすべてのソースコードについて説明できるように」**しましょう。
|
3
訂正
answer
CHANGED
@@ -27,9 +27,6 @@
|
|
27
27
|
var method1 = "easeOutElastic";
|
28
28
|
//var method2 = "easeInBounce";
|
29
29
|
|
30
|
-
|
31
|
-
//ここから以下全て間違い。
|
32
|
-
//jQuery に transition というメソッドは存在しない
|
33
30
|
$(".main .a").animate(
|
34
31
|
{top: 100, marginLeft: 60, bottom: 0, }
|
35
32
|
// , {duration: 800, easing: method1 = 'easeOutElastic'} // ここで代入する意味ない
|
2
タイポ修正
answer
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
|
10
10
|
---
|
11
11
|
|
12
|
-
コードからは、
|
12
|
+
コードからは、どう意図して書いて記述なのか推測できない部分もあるので、おかしいところをコメントで記述しました。
|
13
13
|
|
14
14
|
```javascript
|
15
15
|
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
|
1
追記
answer
CHANGED
@@ -5,4 +5,46 @@
|
|
5
5
|
**手元のコードもしくは現象を確認できるミニマムコードを提示**してください。
|
6
6
|
|
7
7
|
あと、現象が発生するブラウザの種類とバージョンは?
|
8
|
-
最低限、IE(IEの場合はバージョンも)、Chrome、Firefox など数種類の実行結果を書いてください。
|
8
|
+
最低限、IE(IEの場合はバージョンも)、Chrome、Firefox など数種類の実行結果を書いてください。
|
9
|
+
|
10
|
+
---
|
11
|
+
|
12
|
+
コードからは、同意として書いて記述なのか推測できない部分もあるので、おかしいところをコメントで記述しました。
|
13
|
+
|
14
|
+
```javascript
|
15
|
+
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
|
16
|
+
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
|
17
|
+
<script type="text/javascript">
|
18
|
+
$(function () {
|
19
|
+
|
20
|
+
$(".main .a").css({
|
21
|
+
top: '-220px'
|
22
|
+
});
|
23
|
+
//$(window).bind("load", function(){ // 不要 $(function () {で同じ役目
|
24
|
+
$(".main .a").fadeIn(2000);
|
25
|
+
this.blur(); // this がさす内容不明。 documentに成るだろうけど…何の意味???
|
26
|
+
//
|
27
|
+
var method1 = "easeOutElastic";
|
28
|
+
//var method2 = "easeInBounce";
|
29
|
+
|
30
|
+
|
31
|
+
//ここから以下全て間違い。
|
32
|
+
//jQuery に transition というメソッドは存在しない
|
33
|
+
$(".main .a").animate(
|
34
|
+
{top: 100, marginLeft: 60, bottom: 0, }
|
35
|
+
// , {duration: 800, easing: method1 = 'easeOutElastic'} // ここで代入する意味ない
|
36
|
+
, {duration: 800, easing: method1}
|
37
|
+
).animate({marginLeft: 60} // 文法上許容されるブラウザもあるが、配列の最後のカンマは不具合の元
|
38
|
+
//, {duration: 100, easing: method1 = 'easeOutElastic'}// ここで代入する意味ない
|
39
|
+
, {duration: 100, easing: method1}
|
40
|
+
);
|
41
|
+
//jQuery に transition というメソッドは存在しない。
|
42
|
+
//なので、以下全部間違い
|
43
|
+
//何を意図したコードなのかわからないので、コメントなし。
|
44
|
+
// $(".main .a").transition({scaleX: 1.5, scaleX:1.5, duration: 100}, {scaleY: 1.5, scaleY:1.5, duration: 100});
|
45
|
+
// $(".main .a").transition({scaleY: 1.5, scaleY:1.5, duration: 100}, {scaleX: 1.5, scaleX:1.5, duration: 100});
|
46
|
+
// $(".main .a").transition({scaleY: 1.0, scaleY:1.0, duration: 100}, {scaleX: 1.0, scaleX:1.0, duration: 100});
|
47
|
+
// $(".main .a").transition({scaleX: 1.0, scaleX:1.0, duration: 100}, {scaleY: 1.0, scaleY:1.0, duration: 100});
|
48
|
+
});
|
49
|
+
</script>
|
50
|
+
```
|