Replace `ImageView` `el` with auto-oriented `canvas`

See: #998
This commit is contained in:
Daniel Gasienica 2018-02-09 14:35:02 -05:00
parent 1602d7f610
commit f4d3392687
1 changed files with 18 additions and 3 deletions

View File

@ -15,8 +15,19 @@
var ImageView = Backbone.View.extend({
tagName: 'img',
initialize: function(dataUrl) {
this.dataUrl = dataUrl;
initialize: function(objectUrl, contentType, blob) {
loadImage(blob, autoOrientedCanvas => {
this.el.replaceWith(autoOrientedCanvas);
this.render();
this.update();
}, {
orientation: true,
// From CSS:
// maxWidth: 30em --> 420px
// maxHeight: 300px
maxWidth: 420,
maxHeight: 300,
});
},
events: {
'load': 'update',
@ -25,7 +36,11 @@
this.trigger('update');
},
render: function() {
this.$el.attr('src', this.dataUrl);
if (!this.source) {
return this;
}
this.$el.attr('src', this.source);
return this;
}
});