grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

[Question] real responsive device mode

Open tommedema opened this issue 8 years ago • 5 comments

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:

screen shot 2018-04-09 at 4 44 24 pm

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:

screen shot 2018-04-09 at 4 45 16 pm

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:

screen shot 2018-04-09 at 4 47 04 pm

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?

tommedema avatar Apr 09 '18 23:04 tommedema

Build your CSS to with min-width rather than min-device-width etc... and it's all good.

nojacko avatar Apr 13 '18 16:04 nojacko

@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.

tommedema avatar Apr 13 '18 16:04 tommedema

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 :)

artf avatar Apr 14 '18 13:04 artf

Not asking to start a new project, just asking if people have ideas on how this could be achieved.

tommedema avatar Apr 15 '18 02:04 tommedema

@art @tommedema

All you can try is something like this:

http://jsfiddle.net/dirkk0/EEgTx/

More info: https://stackoverflow.com/questions/166160/how-can-i-scale-the-content-of-an-iframe

The problem of not being able to control iframe contents is an old one, not really related to grapesjs.

jmrgz avatar Aug 02 '18 20:08 jmrgz