mirror of
https://github.com/idrawjs/idraw
synced 2026-05-24 10:08:34 +00:00
feat: add getScreenTransform
This commit is contained in:
parent
2290643fd2
commit
ad8a747328
4 changed files with 20 additions and 9 deletions
|
|
@ -10,9 +10,9 @@ export function doScale(core, scale) {
|
|||
}
|
||||
input.addEventListener('change', () => {
|
||||
const val = input.value * 1;
|
||||
console.log('scale ===', val);
|
||||
if (val > 0) {
|
||||
core.scale(val);
|
||||
console.log(core.getScreenTransform());
|
||||
}
|
||||
});
|
||||
hasInited = true;
|
||||
|
|
|
|||
|
|
@ -20,12 +20,14 @@ export function doScroll(core, conf = {}) {
|
|||
const val = inputX.value * 1;
|
||||
if (val >= 0 || val < 0) {
|
||||
core.scrollLeft(val);
|
||||
console.log(core.getScreenTransform());
|
||||
}
|
||||
});
|
||||
inputY.addEventListener('change', () => {
|
||||
const val = inputY.value * 1;
|
||||
if (val >= 0 || val < 0) {
|
||||
core.scrollTop(val);
|
||||
console.log(core.getScreenTransform());
|
||||
}
|
||||
});
|
||||
hasInited = true;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import {
|
||||
TypeData, TypePoint, TypeBoardSizeOptions,
|
||||
TypeHelperWrapperDotDirection, TypeConfig, TypeConfigStrict, TypeElementBase,
|
||||
TypeElement, TypeElemDesc, TypeContext, TypeCoreOptions, TypeScreenContext,
|
||||
TypeElement, TypeElemDesc, TypeContext, TypeCoreOptions, TypeScreenContext, TypeScreenData,
|
||||
} from '@idraw/types';
|
||||
import Board from '@idraw/board';
|
||||
import util from '@idraw/util';
|
||||
|
|
@ -168,6 +168,15 @@ class Core {
|
|||
return screen;
|
||||
}
|
||||
|
||||
getScreenTransform(): TypeScreenData {
|
||||
const transform = this[_board].getTransform();
|
||||
return {
|
||||
scale: transform.scale,
|
||||
scrollTop: Math.max(0, 0 - transform.scrollY),
|
||||
scrollLeft: Math.max(0, 0 - transform.scrollX),
|
||||
}
|
||||
}
|
||||
|
||||
getData(): TypeData {
|
||||
return deepClone(this[_data]);
|
||||
}
|
||||
|
|
@ -439,10 +448,10 @@ class Core {
|
|||
private [_emitChangeScreen]() {
|
||||
if (this[_coreEvent].has('changeScreen')) {
|
||||
this[_coreEvent].trigger('changeScreen', {
|
||||
...this[_board].getTransform(),
|
||||
...{
|
||||
selectedElementUUID: this[_tempData].get('selectedUUID')
|
||||
}
|
||||
...this.getScreenTransform(),
|
||||
// ...{
|
||||
// selectedElementUUID: this[_tempData].get('selectedUUID')
|
||||
// }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
type TypeScreenData = {
|
||||
scale: number;
|
||||
scrollY: number;
|
||||
scrollX: number;
|
||||
selectedElementUUID: string | null;
|
||||
scrollLeft: number;
|
||||
scrollTop: number;
|
||||
// selectedElementUUID: string | null;
|
||||
}
|
||||
|
||||
type TypeScreenPosition = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue