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
[BUG] Custom scale value is overridden by rescale logic during initial widget layout, not able to apply 4 custom parameters during initial image rendering
#289
Describe the bug
The library is awesome and ideally covers my needs. My use case is to remember image rotation, scale, etc. that are done by user. When user opens the same image again, I would like to show the image with previous values. PhotoViewController is an ideal way for this, but my custom scale value is overridden during initial widget layout. Details below
To Reproduce
Configuration 1
Add PhotoView with image.
Use controller to set initial image parameters including scale.
I see issue in the following method, where delegate forces recalculation for scale due to markNeedsScaleRecalc flag that is true:
double get scale {
final needsRecalc = markNeedsScaleRecalc &&
!scaleStateController.scaleState.isScaleStateZooming;
final scaleExistsOnController = controller.scale != null;
if (needsRecalc || !scaleExistsOnController) {
final newScale = getScaleForScaleState(
scaleStateController.scaleState,
scaleBoundaries,
);
markNeedsScaleRecalc = false;
scale = newScale;
return newScale;
}
return controller.scale;
}
What is the current behavior?
All parameters (rotation, position, rotationFocusPoint) except scale are applied. Scale parameter is overridden due to rescale logic.
Expected behavior
Custom scale value is correctly applied to the image.
Configuration 2
Add PhotoView with image.
Use initialScale property to set the scale. Set remaining 3 properties via controller.
What is the current behavior?
Only scale parameter is applied. Rotation, position, rotationFocusPoint are ignored.
Expected behavior
All 4 parameters are applied correctly.
InitialScale looks suitable for this case, moreover it works correctly. I can see that the image is scaled properly, when I set initial scale, but 3 other parameters (rotation, position, rotationFocusPoint) are not applied correctly via controller setMultiply. In other words, I can apply correct scale using initialScale property or I can correctly apply 3 remaining parameters, but only when I do not specify initialScale.
The only workaround that I have is the following. Apply image parameters after build with some delay, but it is bad solution :(
@renancaraujo I've cloned your repo and tried to force the flag markNeedsScaleRecalc to be false. Unfortunately, it doesn't help. PhotoView still doesn't apply all required modifications (scale, rotation, move) to the image correctly.
Dear @renancaraujo, I am so sorry that I've missed this reply from you. Thank you for all your work and great library. I am going to implement supported initial scale in upcoming release! :)
Describe the bug
The library is awesome and ideally covers my needs. My use case is to remember image rotation, scale, etc. that are done by user. When user opens the same image again, I would like to show the image with previous values. PhotoViewController is an ideal way for this, but my custom scale value is overridden during initial widget layout. Details below
To Reproduce
Configuration 1
I see issue in the following method, where delegate forces recalculation for scale due to markNeedsScaleRecalc flag that is true:
What is the current behavior?
All parameters (rotation, position, rotationFocusPoint) except scale are applied. Scale parameter is overridden due to rescale logic.
Expected behavior
Custom scale value is correctly applied to the image.
Configuration 2
What is the current behavior?
Only scale parameter is applied. Rotation, position, rotationFocusPoint are ignored.
Expected behavior
All 4 parameters are applied correctly.
InitialScale looks suitable for this case, moreover it works correctly. I can see that the image is scaled properly, when I set initial scale, but 3 other parameters (rotation, position, rotationFocusPoint) are not applied correctly via controller setMultiply. In other words, I can apply correct scale using initialScale property or I can correctly apply 3 remaining parameters, but only when I do not specify initialScale.
The only workaround that I have is the following. Apply image parameters after build with some delay, but it is bad solution :(
I am not sure if it is a defect or expected behaviour. If it is expected, please let me know how to supported my use case.
The text was updated successfully, but these errors were encountered: