Real responsive device mode
Build your CSS to with min-width rather than min-device-width etc... and it's all good.
Read full answer below ↓Question
You might think that changing an iframe's width to a device width acts the same way as a device emulator would, but in reality it does not.
Here is a case in point: if you load pages.github.io in an iframe with a width of 320px, you'll get:
<img width="359" alt="screen shot 2018-04-09 at 4 44 24 pm" src="https://user-images.githubusercontent.com/331833/38528599-4c6ef62c-3c15-11e8-97e6-6c2bf2448da5.png">You can try it out yourself:
<!doctype html>
<html>
<body>
<iframe src="https://pages.github.com/" width="320" height="568" allowfullscreen></iframe>
</body>
</html>
If you go to pages.github.io and enable chrome's devtools to emulate a device with the same width (320px), it will look much more responsive:
<img width="385" alt="screen shot 2018-04-09 at 4 45 16 pm" src="https://user-images.githubusercontent.com/331833/38528633-6743c5cc-3c15-11e8-97ff-24afbf514a7f.png">What's happening here is that the browser actually respects the forced width of the page (980px forced; there are no media queries in this page), and scales the content to fit. I believe it may also do some further text zooming:
<img width="398" alt="screen shot 2018-04-09 at 4 47 04 pm" src="https://user-images.githubusercontent.com/331833/38528724-a9994bf4-3c15-11e8-8737-e08dcd46f9c8.png">Here you can see that while the device width is 320px, the component width is still 980px. Since the whole component is visible, there must be somekind of viewport scaling going on.
For Grapes to really be a "next generation" WYSIWYG editor, full responsiveness mode seems like a must.
Does anyone have any ideas on how we can achieve the same effect as the devtools emulator? Perhaps by using Javascript to dynamically change the viewport scaling? Or by using CSS transforms in a smart way?
Answers (3)
Build your CSS to with min-width rather than min-device-width etc... and it's all good.
@nojacko that assumes that I have control over the CSS. That's not the case ;)
Also, the above example does not use min-device-width. It simply uses width: 900px. Small devices are smart enough to scale accordingly. A real responsive mode would therefore do the same.
Thanks for the suggestion @tommedema but currently I don't see any value in start working on such improvement, the current implementation works if you want to build a responsive template and this is what really matters. BTW if you really want to work on this PRs are welcome :)
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2968
Question: trying to have 'Settings' sector under the style
https://github.com/artf/grapesjs/issues/1627 I think the question is related to this line specifically, I have the same issue. I look thru...
Issue #4765
The documented way to parse @keyframes does not work
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? Chrome v107Describe the bug How to reproduce...
Issue #3285
[Question]: Doctype in the canvas iframe
Hi. This question has already been asked twice (here and here) but has never got an answer. Is there a way to add <!DOCTYPE html> as the be...
Issue #3267
Cannot set 0px box shadow blur
For some reason, the editor does not allow to set the blur to 0px. 0 always magically turns into 5px. <img width="243" alt="Screenshot 2021...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.
Browse premium plugins →Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.