Skip to content

Commit

Permalink
Merge pull request #357 from RabotaRu/refactoring-zoom
Browse files Browse the repository at this point in the history
Миксин перенесен в папке схем. Унифицирована работа зума и перетаскивания.
  • Loading branch information
rpiontik authored Aug 11, 2023
2 parents 58610ad + e0b06fe commit 79cb38b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
5 changes: 1 addition & 4 deletions src/frontend/components/Schema/DHSchema/DHSchema.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,7 @@
import SchemaTrack from './DHSchemaTrack.vue';
import SchemaDebugNode from './DHSchemaDebugNode.vue';
import ZoomAndPan from '@front/mixins/zoomAndPan';
// require(process.env.VUE_APP_DOCHUB_SMART_ANTS_SOURCE);
import ZoomAndPan from '../zoomAndPan';
const Graph = new function() {
const codeWorker = require(`!!raw-loader!${process.env.VUE_APP_DOCHUB_SMART_ANTS_SOURCE}`).default;
Expand Down
6 changes: 1 addition & 5 deletions src/frontend/components/Schema/PlantUML.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<div
v-else-if="render"
class="plantuml-schema"
v-bind:style="{cursor: cursor}"
v-on:mousedown.prevent="zoomAndPanMouseDown"
v-on:mousemove.prevent="zoomAndPanMouseMove"
v-on:mouseup.prevent="zoomAndPanMouseUp"
Expand Down Expand Up @@ -57,7 +56,7 @@
import copyToClipboard from '@front/helpers/clipboard';
import download from '@front/helpers/download';
import ZoomAndPan from '@front/mixins/zoomAndPan';
import ZoomAndPan from './zoomAndPan';
const EVENT_COPY_SOURCE_TO_CLIPBOARD = 'copysource';
Expand Down Expand Up @@ -129,9 +128,6 @@
);
}
return result.concat(this.menu.items);
},
cursor() {
return this.isShiftSens ? 'move' : undefined;
}
},
watch: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
export default {
data: () => ({
zoomAndPan: {
zoomKey: 'ctrlKey', // Кнопка для зума
panKey: 'shiftKey',
zoomKeys: ['ctrlKey', 'shiftKey'], // Кнопка для зума
panKeys: ['ctrlKey', 'shiftKey'],
isMove: false, // Признак перемещения схемы
isShiftSens: false, // Признак, что пользователь нажал шифт
cacheViewBox: null,
moveX: 0,
moveY: 0,
Expand Down Expand Up @@ -52,8 +51,14 @@ export default {
this.ZoomAndPanViewBox.height += resizeHeight;
this.zoomAndPan.cacheViewBox = null;
},
isPushKey(event, keys) {
for (let i = 0; i < keys.length; i++) {
if (event[keys[i]]) return true;
}
return false;
},
zoomAndPanWheelHandler(event) {
if (!event[this.zoomAndPan.zoomKey]) return;
if (!this.isPushKey(event, this.zoomAndPan.zoomKeys)) return;
let e = window.event || event;
switch (Math.max(-1, Math.min(1, (e.deltaY || -e.detail)))) {
case 1:
Expand All @@ -66,13 +71,12 @@ export default {
event.stopPropagation();
},
zoomAndPanMouseDown(event) {
if (!event[this.zoomAndPan.panKey]) return;
if (!this.isPushKey(event, this.zoomAndPan.panKeys)) return;
this.zoomAndPan.isMove = true;
this.zoomAndPan.moveX = event.clientX;
this.zoomAndPan.moveY = event.clientY;
},
zoomAndPanMouseMove(event) {
this.zoomAndPan.isShiftSens = event[this.zoomAndPan.panKey];
if (!this.zoomAndPan.isMove) return;
this.ZoomAndPanViewBox.x += (this.zoomAndPan.moveX - event.clientX) * (this.koofScreenX || 0);
this.ZoomAndPanViewBox.y += (this.zoomAndPan.moveY - event.clientY) * (this.koofScreenY || 0);
Expand Down

0 comments on commit 79cb38b

Please sign in to comment.