Fix zoom and scroll

This commit is contained in:
barsdeveloper
2023-01-04 17:41:36 +01:00
parent f59217ffd9
commit 39cade4879
11 changed files with 67 additions and 173 deletions

View File

@@ -237,7 +237,7 @@ export default class Blueprint extends IElement {
this.zoom = zoom
if (center) {
requestAnimationFrame(_ => {
//requestAnimationFrame(_ => {
center[0] += this.translateX
center[1] += this.translateY
let relativeScale = this.getScale() / initialScale
@@ -249,12 +249,12 @@ export default class Blueprint extends IElement {
(newCenter[0] - center[0]) * initialScale,
(newCenter[1] - center[1]) * initialScale,
])
})
//})
}
}
getScale() {
return parseFloat(getComputedStyle(this.template.gridElement).getPropertyValue("--ueb-scale"))
return Configuration.scale[this.getZoom()]
}
/** @param {Number[]} param0 */

View File

@@ -131,6 +131,28 @@ export default class Configuration {
variableSet: "/Script/BlueprintGraph.K2Node_VariableSet",
whileLoop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:WhileLoop",
}
static scale = {
[-12]: 0.133333,
[-11]: 0.166666,
[-10]: 0.2,
[-9]: 0.233333,
[-8]: 0.266666,
[-7]: 0.3,
[-6]: 0.333333,
[-5]: 0.375,
[-4]: 0.5,
[-3]: 0.675,
[-2]: 0.75,
[-1]: 0.875,
0: 1,
1: 1.25,
2: 1.375,
3: 1.5,
4: 1.675,
5: 1.75,
6: 1.875,
7: 2,
}
static selectAllKeyboardKey = "(bCtrl=True,Key=A)"
static smoothScrollTime = 1000 // ms
static trackingMouseEventName = {

View File

@@ -205,7 +205,7 @@ export default class Utility {
}
targetType = type
}
if (targetType && !Utility.isValueOfType(value, targetType)) {
if (targetType && !Utility.isValueOfType(value, targetType, true)) {
value = targetType === BigInt
? BigInt(value)
: new targetType(value)

View File

@@ -155,6 +155,7 @@ export default class BlueprintTemplate extends ITemplate {
this.viewportElement.scroll(this.element.scrollX, this.element.scrollY)
}
if (changedProperties.has("zoom")) {
this.element.style.setProperty("--ueb-scale", this.blueprint.getScale())
const previousZoom = changedProperties.get("zoom")
const minZoom = Math.min(previousZoom, this.element.zoom)
const maxZoom = Math.max(previousZoom, this.element.zoom)