Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Top & Bottom Parts of the image is "lost" when zooming in #11

Closed
wooldridgetm opened this issue Aug 5, 2018 · 7 comments
Closed

Top & Bottom Parts of the image is "lost" when zooming in #11

wooldridgetm opened this issue Aug 5, 2018 · 7 comments
Labels
bug Something isn't working

Comments

@wooldridgetm
Copy link

I discovered that when the height of the PhotoView isn't set to full-screen, then after zooming in, the top & bottom parts of the image aren't visible to the user.

I think it's because in _PhotoViewImageWrapperState, Fx _clampPosition(Offset), we're using the screen's width & height instead of the UI Component's width & height.

final screenHeight = MediaQuery.of(context).size.height needs to be final screenHeight = context.size.height (and likewise for width).

Hopefully that all makes sense.
Great job on this, btw. Works great.

@renancaraujo renancaraujo added the bug Something isn't working label Aug 6, 2018
@renancaraujo
Copy link
Member

You are right. I think we should include an example when photo view isn't used as a full-screen widget.

@wooldridgetm
Copy link
Author

I can provide you a link to a repo with an example if you'd like.

@renancaraujo
Copy link
Member

I will see what we can do to avoid that. Further PR is coming.

@sgon00
Copy link

sgon00 commented Aug 10, 2018

This problem does not only happen when zooming in, PhotoViewScaleBoundary.contained will also make the top and bottom parts lost. Check the following screenshots:

contained
entire_image

@sgon00 sgon00 mentioned this issue Aug 10, 2018
@renancaraujo
Copy link
Member

Could you upload the code of this example perhaps?
It would help me to figure out what is causing this weird behavior.

@sgon00
Copy link

sgon00 commented Aug 10, 2018

@renancaraujo sure, the code is very simple.

main.dart

import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Bug Demo',
      theme: ThemeData(
        primarySwatch: Colors.teal,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: Text(''),
        ),
        body: Container(
          child: PhotoView(
            minScale: PhotoViewScaleBoundary.contained,
            maxScale: 3.0,
            backgroundColor: Color.fromRGBO(255, 255, 255, 1.0),
            loadingChild: Center(child: CircularProgressIndicator()),
            imageProvider: AssetImage('assets/100x500.png'),
          )
        ),
      ),
    );
  }
}

pubspec.yaml

dependencies:
  photo_view: ^0.0.4

  assets:
   - assets/100x500.png

assets/100x500.png

100x500

@renancaraujo
Copy link
Member

In order to be used inside a sized box, PhotoView widget must know is size. And that is a hard thing to do. This is a known issue in Flutter. So, I had to install After Layout to make things work right.

Instead of adding this dependency to the main PhotoView class, I've created a new one wrapping it, PhotoViewInline. In this way, anyone who doesn't want to use PhotoView in the inline mode, can take advantage of the tree shaking compiler and not carry After Layout's code into the packaged app.

Sample code:

        body: Container(
          child: PhotoViewInline(
            minScale: PhotoViewScaleBoundary.contained,
            maxScale: 3.0,
            backgroundColor: Color.fromRGBO(255, 255, 255, 1.0),
            loadingChild: Center(child: CircularProgressIndicator()),
            imageProvider: AssetImage('assets/100x500.png'),
          )
        ),

This feature will be available at the 0.0.5 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants