Issue #859Opened February 12, 2018by hibuno2 reactions

[QUESTIONS] Change canvas style

Question

Hi there,

I have some question about canvas style, in this case i have config like this.

var editor = grapesjs.init({
    container : '#gjs',
    canvas: {
        styles: ['/builder/css/builder-desktop.css']
    }
})

By default i use css with name builder-desktop.css for default canvas style. And then i want if i change Device Manager and choose mobile, i can change a canvas style to builder-mobile.css.

Thank you very much

Answers (2)

hibunoFebruary 12, 20182 reactions

Hi there,

Forget it i solve this problem, just add event on change like this.

  editor.on('change:device', function(e) {
    if (e.attributes.device !== 'Desktop') {
      editor.setStyle('/builder/css/builder-mobile.css')
    } else {
      editor.setStyle('/builder/css/builder-desktop.css')
    }
  });

Thank you

lock[bot]September 18, 20190 reactions

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.