Fix positioning of quote button when parents are positioned relatively

This commit is contained in:
Toby Zerner 2017-11-10 17:45:21 +10:30
parent 101af171b1
commit 14215773b3
2 changed files with 21 additions and 8 deletions

View File

@ -1010,19 +1010,27 @@ System.register('flarum/mentions/components/PostQuoteButton', ['flarum/component
$(document).on('mousedown', this.hide.bind(this));
}
}, {
key: 'show',
value: function show(left, top) {
var $this = this.$().show();
var parentOffset = $this.offsetParent().offset();
$this.css('left', left - parentOffset.left).css('top', top - parentOffset.top);
}
}, {
key: 'showStart',
value: function showStart(left, top) {
var $this = this.$();
$this.show().css('left', left).css('top', $(window).scrollTop() + top - $this.outerHeight() - 5);
this.show(left, $(window).scrollTop() + top - $this.outerHeight() - 5);
}
}, {
key: 'showEnd',
value: function showEnd(right, bottom) {
var $this = this.$();
$this.show().css('left', right - $this.outerWidth()).css('top', $(window).scrollTop() + bottom + 5);
this.show(right - $this.outerWidth(), $(window).scrollTop() + bottom + 5);
}
}, {
key: 'hide',

View File

@ -26,20 +26,25 @@ export default class PostQuoteButton extends Button {
$(document).on('mousedown', this.hide.bind(this));
}
show(left, top) {
const $this = this.$().show();
const parentOffset = $this.offsetParent().offset();
$this
.css('left', left - parentOffset.left)
.css('top', top - parentOffset.top);
}
showStart(left, top) {
const $this = this.$();
$this.show()
.css('left', left)
.css('top', $(window).scrollTop() + top - $this.outerHeight() - 5);
this.show(left, $(window).scrollTop() + top - $this.outerHeight() - 5);
}
showEnd(right, bottom) {
const $this = this.$();
$this.show()
.css('left', right - $this.outerWidth())
.css('top', $(window).scrollTop() + bottom + 5)
this.show(right - $this.outerWidth(), $(window).scrollTop() + bottom + 5);
}
hide() {