Browse Source

Move from the DOM the drag prevent in image component

pull/1874/head
Artur Arseniev 8 years ago
parent
commit
89f0ec77cf
  1. 5
      src/dom_components/model/ComponentImage.js
  2. 11
      src/dom_components/view/ComponentImageView.js

5
src/dom_components/model/ComponentImage.js

@ -73,9 +73,8 @@ module.exports = Component.extend(
* @private
*/
getAttrToHTML(...args) {
var attr = Component.prototype.getAttrToHTML.apply(this, args);
delete attr.onmousedown;
var src = this.get('src');
const attr = Component.prototype.getAttrToHTML.apply(this, args);
const src = this.get('src');
if (src) attr.src = src;
return attr;
},

11
src/dom_components/view/ComponentImageView.js

@ -7,7 +7,9 @@ module.exports = ComponentView.extend({
events: {
dblclick: 'onActive',
click: 'initResize',
error: 'onError'
error: 'onError',
dragstart: 'noDrag',
mousedown: 'noDrag'
},
initialize(o) {
@ -84,14 +86,17 @@ module.exports = ComponentView.extend({
if (fallback) this.el.src = fallback;
},
noDrag(ev) {
ev.preventDefault();
return false;
},
render() {
this.renderAttributes();
this.updateSrc();
const { $el, model } = this;
const cls = $el.attr('class') || '';
!model.get('src') && $el.attr('class', `${cls} ${this.classEmpty}`.trim());
// Avoid strange behaviours with drag and drop
$el.attr('onmousedown', 'return false');
this.postRender();
return this;

Loading…
Cancel
Save