-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfloating-action-button.html
360 lines (325 loc) · 11.1 KB
/
floating-action-button.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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
<!DOCTYPE html>
<html lang="en">
<head> {{> head }} </head>
<body>
{{> navbar }}
<main>
{{> intro}}
<div class="container bsa">
<div class="row">
<div class="col s12 m8 offset-m1 xl7 offset-xl1">
<div id="introduction" class="section scrollspy">
<p class="caption">
If you want a fixed floating action button, you can add multiple actions that will appear on hover. Our demo is in the bottom
righthand corner of the page.
</p>
</div>
<pre style="padding-top: 0px;">
<span class="copyMessage">Copied!</span>
<i class="material-icons copyButton">content_copy</i>
<code class="language-html copiedText">
<xmp>
<div class="fixed-action-btn">
<a class="btn-floating btn-large">
<i class="large material-icons">mode_edit</i>
</a>
<ul>
<li><a class="btn-floating"><i class="material-icons">insert_chart</i></a></li>
<li><a class="btn-floating yellow darken-1"><i class="material-icons">format_quote</i></a></li>
<li><a class="btn-floating green"><i class="material-icons">publish</i></a></li>
<li><a class="btn-floating blue"><i class="material-icons">attach_file</i></a></li>
</ul>
</div>
</xmp>
</code>
</pre>
<div id="initialization" class="scrollspy section">
<h3 class="header">Initialization</h5>
<pre style="padding-top: 0px;">
<span class="copyMessage">Copied!</span>
<i class="material-icons copyButton">content_copy</i>
<code class="language-javascript copiedText">
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('.fixed-action-btn');
var instances = M.FloatingActionButton.init(elems, {
// specify options here
});
});
</code>
</pre>
</div>
<div id="options" class="scrollspy section">
<h3 class="header">Options</h3>
<table class="striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>direction</td>
<td>String</td>
<td>'top'</td>
<td>Direction FAB menu opens. Can be 'top', 'right', 'bottom', 'left'</td>
</tr>
<tr>
<td>hoverEnabled</td>
<td>Boolean</td>
<td>true</td>
<td>If true, FAB menu will open on hover instead of click</td>
</tr>
<tr>
<td>toolbarEnabled</td>
<td>Boolean</td>
<td>false</td>
<td>Enable transit the FAB into a toolbar on click</td>
</tr>
</tbody>
</table>
</div>
<div id="methods" class="scrollspy section">
<h5>Methods</h5>
<blockquote>
<p>All the methods are called on the plugin instance. You can get the plugin instance like this: </p>
<pre style="padding-top: 0px;">
<span class="copyMessage">Copied!</span>
<i class="material-icons copyButton">content_copy</i>
<code class="language-javascript copiedText">
var instance = M.FloatingActionButton.getInstance(elem);
</code>
</pre>
</blockquote>
<h5 class="method-header">
.open();
</h5>
<p>Opens FAB.</p>
<pre><code class="language-javascript col s12">
instance.open();
</code></pre>
<h5 class="method-header">
.close();
</h5>
<p>Closes FAB.</p>
<pre><code class="language-javascript col s12">
instance.close();
</code></pre>
<h5 class="method-header">
.destroy();
</h5>
<p>Destroy plugin instance and teardown</p>
<pre><code class="language-javascript col s12">
instance.destroy();
</code></pre>
</div>
<div id="properties" class="scrollspy section">
<h3 class="header">Properties</h3>
<table class="striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>el</td>
<td>Element</td>
<td>The DOM element the plugin was initialized with.</td>
</tr>
<tr>
<td>options</td>
<td>Object</td>
<td>The options the instance was initialized with.</td>
</tr>
<tr>
<td>isOpen</td>
<td>Boolean</td>
<td>Describes open/close state of the FAB.</td>
</tr>
</tbody>
</table>
</div>
<div id="horizontal" class="scrollspy section">
<h3 class="header">Horizontal FAB</h3>
<p>Creating a horizontal FAB is easy! Just set the direction option.</p>
<div style="position: relative; height: 70px;">
<div class="fixed-action-btn horizontal" style="position: absolute; display: inline-block; right: 24px;">
<a class='btn-floating btn-large'>
<i class='large material-icons'>mode_edit</i>
</a>
<ul>
<li>
<a class='btn-floating'>
<i class='material-icons'>insert_chart</i>
</a>
</li>
<li>
<a class="btn-floating yellow darken-1">
<i class="material-icons">format_quote</i>
</a>
</li>
<li>
<a class="btn-floating green">
<i class="material-icons">publish</i>
</a>
</li>
<li>
<a class="btn-floating blue">
<i class="material-icons">attach_file</i>
</a>
</li>
</ul>
</div>
</div>
<pre style="padding-top: 0px;">
<span class="copyMessage">Copied!</span>
<i class="material-icons copyButton">content_copy</i>
<code class="language-javascript copiedText">
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('.fixed-action-btn');
var instances = M.FloatingActionButton.init(elems, {
direction: 'left'
});
});
</code>
</pre>
<div class="fixed-action-btn" style="bottom: 45px; right: 24px;">
<a class='btn-floating btn-large'>
<i class='material-icons'>mode_edit</i>
</a>
<ul>
<li>
<a class='btn-floating'>
<i class='material-icons'>insert_chart</i>
</a>
</li>
<li>
<a class="btn-floating yellow darken-1">
<i class="material-icons">format_quote</i>
</a>
</li>
<li>
<a class="btn-floating green">
<i class="material-icons">publish</i>
</a>
</li>
<li>
<a class="btn-floating blue">
<i class="material-icons">attach_file</i>
</a>
</li>
</ul>
</div>
</div>
<div id="click-only" class="scrollspy section">
<h3 class="header">Click-only FAB</h3>
<p>If you want to disable the hover behaviour, and instead toggle the FAB menu when the user clicks on the large button
(works great on mobile!), just add the
<code class="language-html">click-to-toggle</code> class to the FAB.</p>
<div style="position: relative; height: 70px;">
<div class="fixed-action-btn click-to-toggle" style="position: absolute; right: 24px;">
<a class='btn-floating btn-large'>
<i class='material-icons'>menu</i>
</a>
<ul>
<li>
<a class='btn-floating'>
<i class='material-icons'>insert_chart</i>
</a>
</li>
<li>
<a class="btn-floating yellow darken-1">
<i class="material-icons">format_quote</i>
</a>
</li>
<li>
<a class="btn-floating green">
<i class="material-icons">publish</i>
</a>
</li>
<li>
<a class="btn-floating blue">
<i class="material-icons">attach_file</i>
</a>
</li>
</ul>
</div>
</div>
<pre style="padding-top: 0px;">
<span class="copyMessage">Copied!</span>
<i class="material-icons copyButton">content_copy</i>
<code class="language-javascript copiedText">
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('.fixed-action-btn');
var instances = M.FloatingActionButton.init(elems, {
direction: 'left',
hoverEnabled: false
});
});
</code>
</pre>
</div>
<div id="toolbar" class="scrollspy section">
<h3 class="header">FAB to Toolbar</h3>
<p class="error-text">Deprecated since Version 2.1.0!</p>
<p>Instead of displaying individual button options, you can transition your FAB into a toolbar on click. Just add the
<code class="language-html">toolbar</code> class to the FAB.</p>
<iframe src="fab-toolbar-demo.html" frameborder="0" width="100%" height="100px"></iframe>
<pre style="padding-top: 0px;">
<span class="copyMessage">Copied!</span>
<i class="material-icons copyButton">content_copy</i>
<code class="language-javascript copiedText">
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('.fixed-action-btn');
var instances = M.FloatingActionButton.init(elems, {
toolbarEnabled: true
});
});
</code></pre>
</div>
</div>
<!-- Table of Contents -->
<div class="col hide-on-small-only m3 xl3">
<div class="toc-wrapper">
<div style="height: 1px;">
<ul class="section table-of-contents">
<li>
<a href="#introduction">Introduction</a>
</li>
<li>
<a href="#initialization">Initialization</a>
</li>
<li>
<a href="#options">Options</a>
</li>
<li>
<a href="#methods">Methods</a>
</li>
<li>
<a href="#properties">Properties</a>
</li>
<li>
<a href="#horizontal">Horizontal</a>
</li>
<li>
<a href="#click-only">Click Only FAB</a>
</li>
<li>
<a href="#toolbar">FAB to Toolbar</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</main>
{{> footer }}
<script type="module" src="/src/main.ts"></script>
</body>
</html>