12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- /* ------------------------------------------------------------------------------
- *
- * # Floating action buttons
- *
- * Demo JS code for extra_fab.html page
- *
- * ---------------------------------------------------------------------------- */
- // Setup module
- // ------------------------------
- var FloatingActionButton = function() {
- //
- // Setup module components
- //
- // FAB
- var _componentFab = function() {
- if (!$().stick_in_parent) {
- console.warn('Warning - sticky.min.js is not loaded.');
- return;
- }
- // Add bottom spacing if reached bottom,
- // to avoid footer overlapping
- // -------------------------
-
- $(window).on('scroll', function() {
- if($(window).scrollTop() + $(window).height() > $(document).height() - 40) {
- $('.fab-menu-bottom-left, .fab-menu-bottom-right').addClass('reached-bottom');
- }
- else {
- $('.fab-menu-bottom-left, .fab-menu-bottom-right').removeClass('reached-bottom');
- }
- });
- // Initialize sticky button
- $('#fab-menu-affixed-demo-left, #fab-menu-affixed-demo-right').stick_in_parent({
- offset_top: 20
- });
- };
- //
- // Return objects assigned to module
- //
- return {
- init: function() {
- _componentFab();
- }
- }
- }();
- // Initialize module
- // ------------------------------
- document.addEventListener('DOMContentLoaded', function() {
- FloatingActionButton.init();
- });
|