You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to zoom on a touchscreen of a laptop with two fingers (pinch), the above code always prints "1.0", regardless of the pinch direction.
Expected Behavior:
The above code should yield different zoom levels in relation to the distance between touchpoints. If the distance between the touchpoints is increasing, zoom should increase as well. Otherwise, if the distance is decreasing, zoom should also decrease.
While debugging, I noticed that zoom is calculated in the function calculateZoom by dividing currentCentroidSize / previousCentroidSize. To calculate the CentroidSize the function calculateCentroidSize is used. The function calculateCentroidSize iterates through the list changes (seems to hold the changed touch positions) and averages over the distance of all changes to the Centroid. Interestingly, the list changes always holds only one value, even if two fingers are on the touchscreen, therefore the distance to the centroid is always zero and currentCentroidSize and previousCentroidSize is also zero. To prevent division by zero, calculateZoom checks:
if (currentCentroidSize ==0f|| previousCentroidSize ==0f) {
return1f
}
As a result, zoom is always one and the code works as described in the "Behavior" section.
All the functions described above can be found in TransformGestureDetector.kt.
The text was updated successfully, but these errors were encountered:
Some applications, e.g. Firefox, let you use ctrl + scroll wheel on the mouse to zoom, and this also doesn't work. In this case, the onGesture callback to detectTransformGestures isn't invoked at all.
Tested on:
Compose versions: 1.1.1, 1.2.0-alpha01-dev753
Kotlin versions: 1.6.10, 1.7.0
Java version: openjdk-16.0.1-1
OS: Arch, Windows 11
Code:
Behavior:
Trying to zoom on a touchscreen of a laptop with two fingers (pinch), the above code always prints "1.0", regardless of the pinch direction.
Expected Behavior:
The above code should yield different zoom levels in relation to the distance between touchpoints. If the distance between the touchpoints is increasing, zoom should increase as well. Otherwise, if the distance is decreasing, zoom should also decrease.
While debugging, I noticed that zoom is calculated in the function calculateZoom by dividing currentCentroidSize / previousCentroidSize. To calculate the CentroidSize the function calculateCentroidSize is used. The function calculateCentroidSize iterates through the list changes (seems to hold the changed touch positions) and averages over the distance of all changes to the Centroid. Interestingly, the list changes always holds only one value, even if two fingers are on the touchscreen, therefore the distance to the centroid is always zero and currentCentroidSize and previousCentroidSize is also zero. To prevent division by zero, calculateZoom checks:
As a result, zoom is always one and the code works as described in the "Behavior" section.
All the functions described above can be found in TransformGestureDetector.kt.
The text was updated successfully, but these errors were encountered: