Fixing some bugs, including outzooming too much.

This commit is contained in:
Ad5001 2024-09-17 01:58:34 +02:00
parent 91e4220397
commit a2fa16949a
Signed by: Ad5001
GPG key ID: EF45F9C6AFE20160
3 changed files with 21 additions and 8 deletions

View file

@ -120,6 +120,12 @@ Canvas {
*/
property bool showygrad: false
/*!
\qmlproperty int LogGraphCanvas::maxgradx
Max power of the logarithmic scaled on the x axis in logarithmic mode.
*/
property int maxgradx: 90
/*!
\qmlproperty var LogGraphCanvas::imageLoaders
Dictionary of format {image: [callback.image data]} containing data for defered image loading.

View file

@ -94,9 +94,13 @@ Item {
property int positionChangeTimer: 0
function updatePosition(deltaX, deltaY) {
settingsInstance.xmin = (Modules.Canvas.px2x(Modules.Canvas.x2px(settingsInstance.xmin)-deltaX))
settingsInstance.ymax += deltaY/canvas.yzoom
settingsInstance.ymax = settingsInstance.ymax.toFixed(4)
const unauthorized = [NaN, Infinity, -Infinity]
const xmin = (Modules.Canvas.px2x(Modules.Canvas.x2px(settingsInstance.xmin)-deltaX))
const ymax = settingsInstance.ymax + deltaY/canvas.yzoom
if(!unauthorized.includes(xmin))
settingsInstance.xmin = xmin
if(!unauthorized.includes(ymax))
settingsInstance.ymax = ymax.toFixed(4)
settingsInstance.changed()
parent.positionChanged(deltaX, deltaY)
@ -140,11 +144,14 @@ Item {
}
let newXZoom = (settingsInstance.xzoom+xZoomDelta).toFixed(0)
let newYZoom = (settingsInstance.yzoom+yZoomDelta).toFixed(0)
if(newXZoom == settingsInstance.xzoom) // No change, allow more precision.
// Check if we need to have more precision
if(newXZoom < 10)
newXZoom = (settingsInstance.xzoom+xZoomDelta).toFixed(4)
if(newYZoom == settingsInstance.yzoom) // No change, allow more precision.
if(newYZoom < 10)
newYZoom = (settingsInstance.yzoom+yZoomDelta).toFixed(4)
if(newXZoom > 0.5)
settingsInstance.xzoom = newXZoom
if(newYZoom > 0.5)
settingsInstance.yzoom = newYZoom
settingsInstance.changed()
}

View file

@ -17,7 +17,7 @@
*/
import { Module } from "./modules.mjs"
import { textsup, roundAwayFromZero } from "./utils.mjs"
import { textsup } from "./utils.mjs"
import { Expression } from "./mathlib.mjs"
import Latex from "./math/latex.mjs"