-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
253 lines (193 loc) · 7.12 KB
/
index.html
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Vanery's blog</title>
<meta name="author" content="vanery">
<meta name="description" content="青梅竹马">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta property="og:site_name" content="Vanery's blog"/>
<meta property="og:image" content="undefined"/>
<link href="/favicon.ico" rel="icon" type="image/x-ico">
<link rel="alternate" href="/atom.xml" title="Vanery's blog" type="application/atom+xml">
<link rel="stylesheet" href="/css/style.css" media="screen" type="text/css">
<!--[if lt IE 9]><script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
</head>
<body>
<header id="header" class="inner"><div class="alignleft">
<h1><a href="/">Vanery's blog</a></h1>
<h2><a href="/">青梅枯萎,竹马老去,从此我爱上的人都像你</a></h2>
</div>
<nav id="main-nav" class="alignright">
<ul>
<li> <a href="/atom.xml">RSS</a> </li>
<li><a href="/">首页</a></li>
<li><a href="/archives">存档</a></li>
<li><a href="/about">关于</a></li>
</ul>
<div class="clearfix"></div>
</nav>
<div class="clearfix"></div></header>
<div id="content" class="inner">
<div id="main-col" class="alignleft"><div id="wrapper">
<article class="post">
<div class="post-content">
<header>
<div class="icon"></div>
<time datetime="2014-02-19T02:03:03.000Z"><a href="/2014/02/19/drag/">2月 19 2014</a></time>
<h1 class="title"><a href="/2014/02/19/drag/"></a></h1>
</header>
<div class="entry">
<h2 id="1-">1.拖拽</h2>
<p>一直说热爱前端,又一直这么懒。想了想是应该写些东西了。</p>
<p>虽然每个人的需求不同,但需要解决的问题却是不尽相同的:</p>
<ul>
<li>拖拽(自定义或默认)</li>
<li>内容(自定义或默认)</li>
<li>动画(自定义或默认)</li>
<li>定位(自定义或默认) </li>
</ul>
<hr>
<h3 id="1-1-">1.1拖拽的事件类型:</h3>
<ul>
<li>drag</li>
<li>dragStart</li>
<li>dragEnd </li>
</ul>
<p><strong>说这个之前先发下事件模型</strong>:</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre><span class="keyword">var</span> EventDisp = <span class="function"><span class="keyword">function</span><span class="params">()</span> {</span>
<span class="keyword">this</span>.events = {};
}
<span class="keyword">var</span> EventDisp = {};
EventDisp.events = [];
EventDisp.on = <span class="function"><span class="keyword">function</span><span class="params">(ev, fn)</span> {</span>
<span class="comment">//</span>
};
EventDisp.trigger = <span class="function"><span class="keyword">function</span><span class="params">(ev)</span> {</span>
<span class="comment">//</span>
};
EventDisp.off = <span class="function"><span class="keyword">function</span><span class="params">(ev)</span> {</span>
<span class="comment">//</span>
};
EventDisp.addEvent = <span class="function"><span class="keyword">function</span><span class="params">(elem, etype, fn)</span> {</span>
<span class="comment">//</span>
},
EventDisp.removeEvent = <span class="function"><span class="keyword">function</span><span class="params">(elem, etype, fn)</span> {</span>
<span class="comment">//</span>
};
</pre></td></tr></table></figure>
<p><strong>drag事件</strong>拖拽过程中持续触发的事件,类似于 mousemove: </p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre>1
2
3
4
5
</pre></td><td class="code"><pre>EventDisp.on(elem, <span class="string">"drag"</span>, <span class="function"><span class="keyword">function</span> <span class="params">(ev)</span> {</span>
<span class="comment">//ev.drag、ev.target 拖拽元素本身。</span>
<span class="comment">//ev.pageX 鼠标指针的 X 轴坐标</span>
<span class="comment">//ev.pageY 鼠标指针的 Y 轴坐标</span>
});
</pre></td></tr></table></figure>
<p><strong>dragStart事件</strong>拖拽开始时触发的事件,类似于 mousedown 。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre>1
2
3
4
</pre></td><td class="code"><pre>EventDisp.on(elem, <span class="string">"dragStart"</span>, <span class="function"><span class="keyword">function</span> <span class="params">(ev)</span> {</span>
<span class="comment">//ev.drag 拖拽元素本身。</span>
<span class="comment">//ev.target 触发拖拽的元素。</span>
});
</pre></td></tr></table></figure>
<p><strong>dragEnd事件</strong>拖拽结束后触发的事件,类似于 mouseup。 </p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre>1
2
3
4
</pre></td><td class="code"><pre>EventDisp.on(elem, <span class="string">"dragEnd"</span>, <span class="function"><span class="keyword">function</span> <span class="params">(ev)</span> {</span>
<span class="comment">//ev.drag 拖拽元素本身。</span>
<span class="comment">//ev.target 触发拖拽的元素。</span>
});
</pre></td></tr></table></figure>
<h3 id="2-drag-">2.drag默认参数</h3>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre><span class="comment">/**
* @param target { Object } 拖拽对象
* @param options.axis { String } 拖拽方向
* @param options.container { Object } 拖拽容易
* @param options.handle { String } 指定区域
* @param options.proxy { Boolean } 拖拽代理
* @param options.refresh { Boolean } 更新拖拽
*/</span>
<span class="keyword">var</span> dragO = <span class="keyword">new</span> Drag(target, options);
</pre></td></tr></table></figure>
<p><em>下回继续</em></p>
</div>
<footer>
<div class="clearfix"></div>
</footer>
</div>
</article>
<nav id="pagination">
<div class="clearfix"></div>
</nav></div></div>
<aside id="sidebar" class="alignright">
<div class="search">
<form action="//google.com/search" method="get" accept-charset="utf-8">
<input type="search" name="q" results="0" placeholder="搜索">
<input type="hidden" name="q" value="site:vanery.cn">
</form>
</div>
<div class="widget tagcloud">
<h3 class="title">标签云</h3>
<div class="entry">
<a href="/tags/javascript, drag, dialog/" style="font-size: NaNpx;">javascript, drag, dialog</a>
</div>
</div>
</aside>
<div class="clearfix"></div>
</div>
<footer id="footer" class="inner"><div class="alignleft">
© 2014 vanery
</div>
<div class="clearfix"></div></footer>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="/js/jquery.imagesloaded.min.js"></script>
<script src="/js/gallery.js"></script>
<link rel="stylesheet" href="/fancybox/jquery.fancybox.css" media="screen" type="text/css">
<script src="/fancybox/jquery.fancybox.pack.js"></script>
<script type="text/javascript">
(function($){
$('.fancybox').fancybox();
})(jQuery);
</script>
</body>
</html>