However, I don’t know if there’s a problem with my code, but a user is able to zoom out and view div/s that are meant to be out of view.
I have a notification panel with a right margin of -400px. On click of a button, the panel gets added a class which makes it slide in. The problem is on mobile devices, if a user is to zoom out, the notification panel becomes visible.
Is there anyway to restrict the view/zoom out, but allow zoom in?
If you are just using a margin to shift them then they are not really out of view as such. Does the parent div have overflow:hidden so that stuff outside is hidden? Just placing elements to the right isn’t going to make them disappear as such from wider screens unless you are hiding the overflow.
Ah ye I see, thanks. Indeed it’s just the margin that was pushing the div out of view. The parent is the body. Not a lot I can do here I think because of a full width image, header and footer.
If display is none, and added class on click has display block, the view is fine, but obviously just seems like a quick fadein and not slidein.
Suppose a timeout function would do it… set to display none with negative margin applied…
on click change to display block… timeout…slide in. then slide out…timeout display none.
I think you could just add a wrapper around the slider and set it to 100% width overflow:hidden. You can then just slide the panel in as normal then. Maybe set opacity to zero and fade it in with css as well…
I would use transform:translateX() rather than margin as it is smoother.
That should work but would give a concertina effect although if you have content inside this element you may find the content inside doesn’t animate. Transforms are still smoother though.