Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Example for alignment option #298

Merged
merged 1 commit into from
Dec 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions pug/page-contents/dropdown_content.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,71 @@ <h3 class="header">Options</h3>
</tr>
</tbody>
</table>
<div id="options-examples">
<h4>Examples</h4>

<!-- Dropdown Trigger 1 -->
<a id="left" class='dropdown-trigger btn' href='#' data-target='dropdown1' style='width: 200px'>Left DropDown!</a>

<!-- Dropdown Structure 1 -->
<ul id='dropdown1' class='dropdown-content'>
<li><a href="#!">one</a></li>
<li><a href="#!">two</a></li>
<li class="divider" tabindex="-1"></li>
<li><a href="#!">three</a></li>
<li><a href="#!"><i class="material-icons">view_module</i>four</a></li>
<li><a href="#!"><i class="material-icons">cloud</i>five</a></li>
</ul>

<!-- Dropdown Trigger 2 -->
<a id="right" class='dropdown-trigger btn' href='#' data-target='dropdown2' style='width: 200px'>Right DropDown!</a>

<!-- Dropdown Structure 2 -->
<ul id='dropdown2' class='dropdown-content'>
<li><a href="#!">one</a></li>
<li><a href="#!">two</a></li>
<li class="divider" tabindex="-1"></li>
<li><a href="#!">three</a></li>
<li><a href="#!"><i class="material-icons">view_module</i>four</a></li>
<li><a href="#!"><i class="material-icons">cloud</i>five</a></li>
</ul>

<script>
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('.dropdown-trigger')[0];
var instances = M.Dropdown.init(elems, {
// the dropdown is aligned to left
alignment: 'left',
// enabled for example to be visible
constrainWidth: false,
});
});

document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('.dropdown-trigger')[1];
var instances = M.Dropdown.init(elems, {
// the dropdown is aligned to left
alignment: 'right',
// enabled for example to be visible
constrainWidth: false,
});
});

</script>

<code class="language-javascript col s12 copiedText">
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('.dropdown-trigger')[0];
var instances = M.Dropdown.init(elems, {
// the dropdown is aligned to left
alignment: 'left',
// enabled for example to be visible
constrainWidth: false,
});
});
</code>

</div>
</div>

<div id="methods" class="scrollspy section">
Expand Down