Fix image resizing when aligned right

[MAILPOET-2184]
This commit is contained in:
Ján Mikláš
2019-08-21 14:59:43 +02:00
committed by M. Shull
parent 82123afc7c
commit 596eb56c5d
3 changed files with 18 additions and 3 deletions

View File

@@ -60,6 +60,12 @@ $resize-handle-z-index: 2;
width: 24px;
}
.mailpoet_image_resize_handle_container_left {
left: 0;
right: auto;
transform: rotate(90deg);
}
.mailpoet_image_resize_handle {
background: $editor-content-color;
border-radius: 6px 0 0;
@@ -78,6 +84,10 @@ $resize-handle-z-index: 2;
.mailpoet_image_resize_handle_icon {
pointer-events: none;
}
.mailpoet_image_resize_handle_container_left & {
cursor: nesw-resize;
}
}
.mailpoet_image_resize_handle_icon {

View File

@@ -46,9 +46,14 @@ Module.ImageBlockView = base.BlockView.extend({
elementSelector: '.mailpoet_image',
resizeHandleSelector: '.mailpoet_image_resize_handle',
onResize: function (event) {
var alignment = this.view.model.get('styles.block.textAlign');
var corner = this.$('.mailpoet_image').offset();
var width = event.pageX - corner.left;
this.view.model.set('width', width + 'px');
var currentWidth = this.$('.mailpoet_image').width();
var newWidth = event.pageX - corner.left;
if (alignment === 'right') {
newWidth = currentWidth + corner.left - event.pageX;
}
this.view.model.set('width', newWidth + 'px');
},
},
ShowSettingsBehavior: {

View File

@@ -4,7 +4,7 @@
<a href="{{ model.link }}" onClick="return false;">
<img src="{{#ifCond model.src '!=' ''}}{{ model.src }}{{ else }}{{ imageMissingSrc }}{{/ifCond}}" alt="{{ model.alt }}" onerror="if(this.src != '{{ imageMissingSrc }}') {this.src = '{{ imageMissingSrc }}';}" width="{{model.width}}" />
</a>
<div class="mailpoet_image_resize_handle_container">
<div class="mailpoet_image_resize_handle_container{{#ifCond model.styles.block.textAlign '==' 'right'}} mailpoet_image_resize_handle_container_left{{/ifCond}}">
<div class="mailpoet_image_resize_handle">
<span class="mailpoet_image_resize_handle_icon"><%= source('newsletter/templates/svg/block-tools/resize.svg') %></span>
</div>