I'm working on a mobile site. Like many mobile sites, it has a hamburger button that when pressed, causes a menu to slide over from the side of the page. The menu covers about 80% of the width of the page. So you still see a strip of the page under the menu, to the right of it.
It doesn't look right, the page needs to be darkened out somehow to direct full focus to the open menu.
The easy way to do this was to simply add a box shadow to the menu. However this box shadow slides in and how with the menu, and that is slowwwww on Android phones. It works great on iPhones but not android.
So I'm switching to plan B: No box shadow. Then I add a fixed position DIV to the page, black background, opacity 0.7. It goes between the menu and the page. Now the new problem is, I want to animate this fading in and out.
The best way I can think of doing that is setting a transition on the opacity. But in order to implement, I'd need to initiate this in javascript, then also set a timer in javascript that matches the timer on the CSS so that when the animation is done, I can then add 'display: none' to make the now fully transparent item disappear.
This plan B should work. But I'm wondering if I'm taking the long route to my destination. Is there a simpler, more logical way to do this?