refactor: Extract modal backdrop close and scrollToTop to functions
- Add closeOnBackdrop(modal, evt) to utils._hs for modal backdrop clicks - Add scrollToTop(evt) to utils._hs for smooth scroll to top - Simplify 3 modal templates (shortcuts, info, pdf) from 4 lines to 1 - Simplify back-to-top button from 3 lines to 1
This commit is contained in:
@@ -170,6 +170,25 @@ def setFooterHover(show)
|
||||
end
|
||||
end
|
||||
|
||||
-- ==============================================================================
|
||||
-- MODAL HELPERS
|
||||
-- ==============================================================================
|
||||
-- Close modal when clicking backdrop (outside content)
|
||||
def closeOnBackdrop(modal, evt)
|
||||
if evt.target is modal
|
||||
call modal.close()
|
||||
end
|
||||
end
|
||||
|
||||
-- ==============================================================================
|
||||
-- SCROLL HELPERS
|
||||
-- ==============================================================================
|
||||
-- Smooth scroll to top of page
|
||||
def scrollToTop(evt)
|
||||
call evt.preventDefault()
|
||||
call window.scrollTo({top: 0, behavior: 'smooth'})
|
||||
end
|
||||
|
||||
-- ==============================================================================
|
||||
-- NAVIGATION SCROLL
|
||||
-- ==============================================================================
|
||||
|
||||
Reference in New Issue
Block a user