Issue #738Opened January 10, 2018by theanhmx0 reactions

image reverted to original size after resized

Question

hi, i got a strange issue with component: i got 2 types, image and icon

domComponents.addType('icon', {
  model: imageModel.extend({
    defaults: Object.assign({}, imageModel.prototype.defaults, {
      traits: [{
        type: 'text',
        label: 'icon URL',
        name: 'src',
        changeProp: 1
      }],
      removable: false,
      draggable: false,
      droppable: false,
      badgable: false,
      stylable: false,
      highlightable: true,
      copyable: false,
      resizable: false,
      editable: true,
      selectable: true
    })
  }, {
    isComponent: function(el) {
      if (el.getAttribute !== undefined && el.getAttribute('deletable') == '0' && el.tagName == 'IMG') {
        return {
          type: 'icon'
        };
      }
    }
  }),
  view: imageView.extend({
    initialize: function() {
      var defaultClickEventHandler = this.events.click || function() {};
      var defaultDblClickEventHandler = this.events.dblclick || function() {};
      defaultView.prototype.initialize.apply(this, arguments);
      this.events.dblclick = function() {
        console.log('dblclick');
      };
    }
  }),
  onValueChange: function() {
    this.target.set('src', this.model.get('value'));
  }
});

domComponents.addType('image', {
  model: imageModel.extend({
    defaults: Object.assign({}, imageModel.prototype.defaults, {
      traits: [{
        type: 'text',
        label: 'Image URL',
        name: 'src',
        changeProp: 1
      }]
    })
  }, {
    isComponent: function(el) {
      if (el.tagName == 'IMG') {
        return {
          type: 'image'
        };
      }
    }
  }),
  view: imageView,
  onValueChange: function() {
    this.target.set('src', this.model.get('value'));
  }
});

the issue is when i first drag and drop the image component, i'm able to resize and save it, but when i load the template again, i'm not able to resize the image again. i can adjust the image size but after couple of second it will be reverted. i noticed there are component:update and component:styleUpdate event fired. is this have anything to do with the angularjs digest cycle? i'm using with angular 1.3

Answers (3)

artfJanuary 10, 20180 reactions

Are you sure there are no strange styles loaded which forces img style? Try to inspect and see if style actually changes

theanhmxJanuary 11, 20180 reactions

yes, i can see it change in the local storage. but after some short time it changed back

artfJanuary 11, 20180 reactions

Are you able to reproduce it with a live example?

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.