Fixing some bugs, including outzooming too much.
This commit is contained in:
parent
91e4220397
commit
a2fa16949a
3 changed files with 21 additions and 8 deletions
|
@ -120,6 +120,12 @@ Canvas {
|
||||||
*/
|
*/
|
||||||
property bool showygrad: false
|
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
|
\qmlproperty var LogGraphCanvas::imageLoaders
|
||||||
Dictionary of format {image: [callback.image data]} containing data for defered image loading.
|
Dictionary of format {image: [callback.image data]} containing data for defered image loading.
|
||||||
|
|
|
@ -94,9 +94,13 @@ Item {
|
||||||
property int positionChangeTimer: 0
|
property int positionChangeTimer: 0
|
||||||
|
|
||||||
function updatePosition(deltaX, deltaY) {
|
function updatePosition(deltaX, deltaY) {
|
||||||
settingsInstance.xmin = (Modules.Canvas.px2x(Modules.Canvas.x2px(settingsInstance.xmin)-deltaX))
|
const unauthorized = [NaN, Infinity, -Infinity]
|
||||||
settingsInstance.ymax += deltaY/canvas.yzoom
|
const xmin = (Modules.Canvas.px2x(Modules.Canvas.x2px(settingsInstance.xmin)-deltaX))
|
||||||
settingsInstance.ymax = settingsInstance.ymax.toFixed(4)
|
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()
|
settingsInstance.changed()
|
||||||
parent.positionChanged(deltaX, deltaY)
|
parent.positionChanged(deltaX, deltaY)
|
||||||
|
|
||||||
|
@ -140,12 +144,15 @@ Item {
|
||||||
}
|
}
|
||||||
let newXZoom = (settingsInstance.xzoom+xZoomDelta).toFixed(0)
|
let newXZoom = (settingsInstance.xzoom+xZoomDelta).toFixed(0)
|
||||||
let newYZoom = (settingsInstance.yzoom+yZoomDelta).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)
|
newXZoom = (settingsInstance.xzoom+xZoomDelta).toFixed(4)
|
||||||
if(newYZoom == settingsInstance.yzoom) // No change, allow more precision.
|
if(newYZoom < 10)
|
||||||
newYZoom = (settingsInstance.yzoom+yZoomDelta).toFixed(4)
|
newYZoom = (settingsInstance.yzoom+yZoomDelta).toFixed(4)
|
||||||
settingsInstance.xzoom = newXZoom
|
if(newXZoom > 0.5)
|
||||||
settingsInstance.yzoom = newYZoom
|
settingsInstance.xzoom = newXZoom
|
||||||
|
if(newYZoom > 0.5)
|
||||||
|
settingsInstance.yzoom = newYZoom
|
||||||
settingsInstance.changed()
|
settingsInstance.changed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Module } from "./modules.mjs"
|
import { Module } from "./modules.mjs"
|
||||||
import { textsup, roundAwayFromZero } from "./utils.mjs"
|
import { textsup } from "./utils.mjs"
|
||||||
import { Expression } from "./mathlib.mjs"
|
import { Expression } from "./mathlib.mjs"
|
||||||
import Latex from "./math/latex.mjs"
|
import Latex from "./math/latex.mjs"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue