LT-370: Repositioning the Add label button
This commit is contained in:
1 parent
d2095f3cb7
commit
bcbd1a4465
8 files changed
+74
-16
No files matched your search
@@ -1,8 +1,8 @@
|
||||
<template name="measureFlow">
|
||||
<div class="measure-flow {{#if this.threeColumns}}tree-columns{{/if}} {{instance.state.get}}"
|
||||
style="top:{{choose position.y 0}}px;left:{{choose position.x 0}}px"
|
||||
style="top:{{choose position.y 0}}px; left:{{choose position.x 0}}px"
|
||||
tabindex="-1">
|
||||
<button class="btn-add">
|
||||
<button class="btn-add" style="visibility: hidden">
|
||||
{{#if this.measurement.location}}Edit{{else}}Add{{/if}} label
|
||||
</button>
|
||||
{{#if eq instance.state.get 'selected'}}
|
||||
|
||||
@@ -76,17 +76,39 @@ Template.measureFlow.onCreated(() => {
|
||||
|
||||
Template.measureFlow.onRendered(() => {
|
||||
const instance = Template.instance();
|
||||
const $measureFlow = instance.$('.measure-flow');
|
||||
const $btnAdd = instance.$('.btn-add');
|
||||
|
||||
// Make the measure flow bounded by the window borders
|
||||
instance.$('.measure-flow').bounded();
|
||||
$measureFlow.bounded();
|
||||
|
||||
instance.$('.btn-add').focus();
|
||||
$btnAdd.focus();
|
||||
|
||||
if (instance.data.autoClick) {
|
||||
instance.$('.btn-add').hide().trigger('click', {
|
||||
$btnAdd.trigger('click', {
|
||||
clientX: instance.data.position.x,
|
||||
clientY: instance.data.position.Y
|
||||
});
|
||||
} else {
|
||||
if (instance.data.direction) {
|
||||
const direction = instance.data.direction;
|
||||
let { left, top } = $measureFlow.offset();
|
||||
|
||||
left = direction.x === -1 ? left -= $btnAdd.outerWidth() : left;
|
||||
top = direction.y === -1 ? top -= $btnAdd.outerHeight() : top;
|
||||
|
||||
const distance = 5;
|
||||
left += direction.x * distance;
|
||||
top += direction.y * distance;
|
||||
|
||||
$measureFlow.css({
|
||||
left,
|
||||
top
|
||||
});
|
||||
}
|
||||
|
||||
// Display the button after reposition it
|
||||
$btnAdd.css('visibility', '');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user