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
|
||||
|
||||
/*!
|
||||
\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.
|
||||
|
|
|
@ -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,12 +144,15 @@ 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)
|
||||
settingsInstance.xzoom = newXZoom
|
||||
settingsInstance.yzoom = newYZoom
|
||||
if(newXZoom > 0.5)
|
||||
settingsInstance.xzoom = newXZoom
|
||||
if(newYZoom > 0.5)
|
||||
settingsInstance.yzoom = newYZoom
|
||||
settingsInstance.changed()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
Loading…
Reference in a new issue