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

Disable hiding of hamburger menu upon resize <= 1024px width #2924

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Extend the "offCanvasWrap" directive in "angular-foundation" to disable hiding of the off-canvas
# upon window resize.
#
# In some browsers for mobile devices, the address bar is automatically hidden when scrolling down
# the page. This is not workable if the height of the contents of the off-canvas exceeds the height
# of the screen, because the latter portion of the contents stays hidden to the user.
#
# However, for screens over 1024px width for which the off-canvas is not styled to be visible, we
# can proceed to hide this.
#
# https://github.com/openfoodfoundation/angular-foundation/blob/0.9.0-20180826174721/src/offcanvas/offcanvas.js
angular.module('mm.foundation.offcanvas').directive 'offCanvasWrap', ($window) ->
{
restrict: 'C'
priority: 1
link: ($scope, element, attrs) ->
win = angular.element($window)

# Get the scope used by the "offCanvasWrap" directive:
# https://github.com/openfoodfoundation/angular-foundation/blob/0.9.0-20180826174721/src/offcanvas/offcanvas.js#L2
isolatedScope = element.isolateScope()

# Unbind hiding of the off-canvas upon window resize.
win.unbind('resize.body', isolatedScope.hide)

# Bind hiding of the off-canvas that only happens when screen width is over 1024px.
win.bind 'resize.body', ->
isolatedScope.hide() if $(window).width() > 1024
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}