-
Notifications
You must be signed in to change notification settings - Fork 216
suggestion: allow closing of off-screen menu by click outside of the menu #430
Comments
Definitely, we need this functionality for off-canvas and panels. |
+1 |
+1, especially for panels! |
+1 |
1 similar comment
+1 |
+1 |
any progress on this? |
@gakimball I believe the same solution used for auto-closing of action sheets when clicked outside should also work for closing of off-canvas and panels. Perhaps refactor the code into a reusable service to be used for any component? |
@gakimball did you mean
I prefer the approach used by the actionsheets wherein the developer does not need to set anything up for the auto-close functionality to work as it's just part of the component (solves 4). It's basically doing the same thing as The only thing I could think of for why this approach may not work is if a developer didn't want the auto-close functionality for that component. In this case an attribute could be added to the element which is read during the compile phase of the directive. If the attribute is present, the auto-close functionality is disabled, otherwise it is enabled by default. I'll take a go at the PR since it should be fairly straightforward. |
I was searching for zfClosable instead of zf-closable in the code base. Let me see what can be done with |
Ok, so I think I'm not a huge fan of this approach as it will not work for everyone. From what I can tell, F4A is being designed so that it could be used by anyone, regardless of how little or how much they know about angular. The solution above will require the FoundationApi to be exposed in the scope, which will require defining your own angular code (unless this can be done in the front matter, which I'm not sure it should be). To solve this, a reference to the FoundationApi service could be added to the $rootScope on loading of foundation so that the following could be used |
After thinking about it, I still would prefer this feature to work out of the box with no additional code required, meaning the code to resolve this issue should reside inside the foundation code base, versus requiring additional angular directives to use this feature. Perhaps foundation could add a default click handler to the body which always calls |
+1 |
4 similar comments
+1 |
+1 |
+1 |
+1 |
+1 Is this ever coming in? And how would you work around this untill its added? |
@Martinspire You can implement this feature my adding the following attribute to any element you want to have close the off canvas (in my example the off canvas has id app-menu).
Where closeAppMenu is the following function on the scope. You might not need the $scope.closeAppMenu = function() {
$timeout(function() {
FoundationApi.publish('app-menu', 'close');
});
}; Note that I did not add the click handler to the body as the body also contains the off canvas menu. I added the click handler to the root element containing my views so that clicking inside the off canvas does not lose the menu. In some cases where I need the menu to close when I click a link inside the off canvas, I've added the following element to the link:
|
Nearly done with this feature... |
Done. Add |
…n anything other than their respective contents. fixes #430
This should really be somewhere in the offcanvas menu or panel documentation - this is something almost every designing for mobile will want. |
ZURB has basically dropped support for this framework and it is now being developed by the community here: https://github.com/base-apps/angular-base-apps Feel free to submit a PR to improve the documentation |
would it be a possibility to allow a user to hide an off-screen panel simply by clicking anywhere outside of the panel? As it works now, i believe you can only close an off-screen panel or menu by clicking on a zf-close or zf-toggle element. It would be great if, after a user opens/toggles an off-screen panel/menu, they could click anywhere on the viewport, outside of the panel, to close that panel.
The text was updated successfully, but these errors were encountered: