ionic-img-viewer icon indicating copy to clipboard operation
ionic-img-viewer copied to clipboard

Support multiple pictures show, left and right sliding display

Open jianminLee opened this issue 8 years ago • 53 comments

sorry,my English is bad.... I have added more pictures to slide show。 It is necessary to explain here

  updateImageSrc(src) {
    if (Array.isArray(src)) {
      let srcLen = src.length;
      let safeImage: SafeUrl[] = [];
      for (let i = 0; i < srcLen; i++) {
        if(this.originalSrc === src[i]){
          this.imageCurIndex = i;
        }
        if(i === 0){
          this.imageChange = this._sanitizer.bypassSecurityTrustUrl(src[i]);
          safeImage = safeImage.concat(this.imageUrl);
          continue;
        }
        safeImage.push(this._sanitizer.bypassSecurityTrustUrl(src[i]));
      }
      this.imageUrl = safeImage;
    } else {
      this.originalSrc = src;
      this.imageUrl.push(this._sanitizer.bypassSecurityTrustUrl(src));
    }
  }

Because of the animation, I have to do a lot of operations here, if you choose a picture of a, I need to show that the effect of animation, and then slide to show before or after the picture, I really no better The way.

Use the same as before, just can be passed to the array or a single image URL.

Thank you again, this project is very helpful for my work, the animation is very cool, of course, the hope of the code for your project also help。

jianminLee avatar Jun 29 '17 09:06 jianminLee

Thanks for the PR 👍 That's a lot of code ! I will try to give it a look ASAP

Riron avatar Jul 10 '17 16:07 Riron

is this support available now? How to use this feature?

Muneem avatar Aug 17 '17 11:08 Muneem

how can fetch this

junyung1261 avatar Aug 17 '17 11:08 junyung1261

@Muneem

<img item-right src="{{post.imgSrc[0]}}" imageViewer="{{post.imgSrc}}">

Like a document, just an array is passed in

jianminLee avatar Aug 17 '17 11:08 jianminLee

so is it possible to add ion-slide in imageViewer?. I mean its more like gallery where user cal slide images also and they can zoom? is this support available?

Muneem avatar Aug 17 '17 11:08 Muneem

@Muneem
of course

jianminLee avatar Aug 17 '17 11:08 jianminLee

How? Right now its only one image. I want to add ion-slide inside imageviewer

Muneem avatar Aug 17 '17 11:08 Muneem

@Muneem

You have to use my pull request

jianminLee avatar Aug 17 '17 11:08 jianminLee

@jianminLee ok then how would i use that feature? there is no documentation of how to use that feauture

Muneem avatar Aug 17 '17 11:08 Muneem

@Muneem

See the author's document just fine, I just added a function, and this function only need you to the array, the above reply I have given the code

jianminLee avatar Aug 17 '17 11:08 jianminLee

@jianminLee do you have working example of this feature?

Muneem avatar Aug 17 '17 11:08 Muneem

@Muneem

There are examples in the author's document

<img item-right src="{{post.imgSrc[0]}}" imageViewer="{{post.imgSrc}}">

or

this.imageView.create(event.srcElement, {fullResImage: imgArr}).present();

imgArr and post.imgSrc can be an array or a string

jianminLee avatar Aug 17 '17 12:08 jianminLee

@jianminLee i have provided array but its not showing me next images in slider. it is just opening that image where i am clicking

Muneem avatar Aug 17 '17 12:08 Muneem

@Muneem

Are you sure you're using my pull request?

Please get the code here

https://github.com/jianminLee/ionic-img-viewer

jianminLee avatar Aug 17 '17 12:08 jianminLee

How to use this as npm package? I have used npm install git+ your repo. but its giving me unmet peerdependency error

Muneem avatar Aug 17 '17 12:08 Muneem

@Muneem

Posted an error message

jianminLee avatar Aug 17 '17 12:08 jianminLee

screen shot 2017-08-17 at 4 33 18 pm

Muneem avatar Aug 17 '17 12:08 Muneem

@Muneem This is the problem with the ionic framework. You can try running the program to see if it works, otherwise you can only upgrade your

jianminLee avatar Aug 17 '17 12:08 jianminLee

@jianminLee i am using latest ionic configuration. All my things are latest. I think your branch is old so i have to downgrade few things to test this functionality

Muneem avatar Aug 17 '17 12:08 Muneem

@Muneem

I'm sorry, I did not look at the wrong message carefully. I run in ionic-angular 3.6.0, no problem

jianminLee avatar Aug 17 '17 12:08 jianminLee

@jianminLee i downgraded my version. now its installed. but still its opening one image only. i have supplied imageViewer to my array but it is not showing me other images.

Muneem avatar Aug 17 '17 12:08 Muneem

@Muneem

You do not need to downgrade, I have updated it Package.json, if there is an error please posted your code

jianminLee avatar Aug 17 '17 12:08 jianminLee

@jianminLee when i give array then it only opens 1 image and in console i get error 400 status error

Muneem avatar Aug 17 '17 12:08 Muneem

  <ion-slide *ngFor="let image of media" class="image-slides">
      <img src={{image}} imageViewer="{{media}}">
    </ion-slide>

Muneem avatar Aug 17 '17 12:08 Muneem

this is my code how i am using this

Muneem avatar Aug 17 '17 12:08 Muneem

<img item-right src="{{post.imgSrc[0]}}" imageViewer="{{post.imgSrc}}">

You do not need to use ion-slides Just add imageViewer = "{{post.imgSrc}} to your image element, Post.imgSrc is your array of pictures src, for example:

Post.imgSrc = ['http://xxxx.xxx/xxx.jpg','http://xxxx.xxx/xxx.jpg','http://xxxx.xxx/xxx.jpg','http: //xxxx.xxx/xxx.jpg '];

jianminLee avatar Aug 17 '17 12:08 jianminLee

its same. I am passing array of images. It should open that

Muneem avatar Aug 17 '17 12:08 Muneem

How you are generating img src? As i am getting error and i see its wrong src

Muneem avatar Aug 17 '17 12:08 Muneem

I found issue. I am passing array of images. And you are using this as src. You are not breaking it or yo are not considering it as array of images

Muneem avatar Aug 17 '17 13:08 Muneem

@Muneem

I do not understand what you mean, can you put the complete code?

jianminLee avatar Aug 17 '17 13:08 jianminLee

This is request object these all are array object so it is appending all this in 1 request

Muneem avatar Aug 17 '17 13:08 Muneem

one more thing can you please send me screenshot of what you have implemente?

Muneem avatar Aug 17 '17 13:08 Muneem

have you check request object?screenshot which i have posted?

Muneem avatar Aug 17 '17 13:08 Muneem

@Muneem

Post.imgSrc = ['http://xxxx.xxx/xxx.jpg','http://xxxx.xxx/xxx.jpg','http://xxxx.xxx/xxx.jpg','http: //xxxx.xxx/xxx.jpg '];

You can try to http://xxxx.xxx/xxx.jpg all replaced by a valid image url, look at the effect. Casually to google a few pictures of the url

jianminLee avatar Aug 17 '17 13:08 jianminLee

@Muneem

Then like this:

      <ion-thumbnail item-right *ngIf="post.imgSrc.length">
        <img item-right src="{{post.imgSrc[0]}}" imageViewer="{{post.imgSrc}}">
      </ion-thumbnail>

jianminLee avatar Aug 17 '17 13:08 jianminLee

@jianminLee can you please tell me how could i include this in ionic project? As through npm installl i am unable to include your branch in my ionic project

Muneem avatar Aug 17 '17 13:08 Muneem

@Muneem

npm install https://github.com/jianminLee/ionic-img-viewer.git

This is not what?

jianminLee avatar Aug 17 '17 14:08 jianminLee

When i run npm install it foes not install from your branch

Get Outlook for Androidhttps://aka.ms/ghei36


From: jianmingLee [email protected] Sent: Thursday, August 17, 2017 6:03:39 PM To: Riron/ionic-img-viewer Cc: Muneem; Mention Subject: Re: [Riron/ionic-img-viewer] Support multiple pictures show, left and right sliding display (#68)

@Muneemhttps://github.com/muneem

npm install https://github.com/jianminLee/ionic-img-viewer.git

This is not what?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Riron/ionic-img-viewer/pull/68#issuecomment-323083288, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AGRcTP7U9XAsHHhaMaXWyr0omGqaE6x_ks5sZEg7gaJpZM4OJCGh.

Muneem avatar Aug 17 '17 14:08 Muneem

@Muneem

If not, then I have no good idea, you can download directly to use

jianminLee avatar Aug 17 '17 14:08 jianminLee

these all changes are present here: https://github.com/jianminLee/ionic-img-viewer

Muneem avatar Aug 17 '17 14:08 Muneem

?

Muneem avatar Aug 17 '17 14:08 Muneem

@Muneem

Yes I will merge all the changes to the author

jianminLee avatar Aug 17 '17 14:08 jianminLee

@jianminLee one suggestion put it in master and generate new npm version also.

Muneem avatar Aug 17 '17 15:08 Muneem

how can i get this branch?? im using ionic 3.9.2

junyung1261 avatar Dec 22 '17 08:12 junyung1261

Currently it won't install because @jianminLee has an invalid semver version in the package.json. Sent a PR for that. Hopefully it will be merged, and hopefully that will get merged here!

seiyria avatar Mar 18 '18 15:03 seiyria

+1, would be useful

C1PR14N055 avatar Mar 23 '18 09:03 C1PR14N055

This is THE feature. It would be the best plugin if this kind of support would be added.

LufoX11 avatar May 08 '18 19:05 LufoX11

Hi, will this branch be merged with master ? I'm really interested by this feature !

AnthonyBillon avatar May 31 '18 21:05 AnthonyBillon

Hi, Am using "https://github.com/jianminLee/ionic-img-viewer/" to display the array of images by following your instructions. But there is one issue . InitialSlide attribute which am passing from my application based on user selection is not setting the image in the ion-slide immediately . There is a slight delay. Assume on clicking on the third image, am getting the first image for a second and then i get the proper image.

Shals08 avatar Jun 11 '18 03:06 Shals08

@Shals08 look this issue! https://github.com/ionic-team/ionic/issues/9819

jianminLee avatar Jun 11 '18 04:06 jianminLee

@jianminLee
Thanks.... Oh issue in ionic :(.

Shals08 avatar Jun 11 '18 08:06 Shals08

This worked for me

 <ion-slides   *ngIf="images && images.length"   style="overflow: hidden" [autoplay]="2000" [loop]="true"  speed="1000">
      <div *ngFor="let mage of images ;let i = index">
        <ion-slide >
               <img src="{{mage}}"  (click)="itemSelected($event.target)" imageViewer  >
       </ion-slide>
      </div>
 </ion-slides>
import {ImageViewerController} from 'ionic-img-viewer';

 constructor(private imageViewerCtrl : ImageViewerController){
}
  itemSelected(imageToView) 
{
    const viewer = this.imageViewerCtrl.create(imageToView)
    viewer.present();
  }

A7medHub avatar Jan 31 '19 13:01 A7medHub

ionic4 angular7 This worked for me. https://www.freakyjolly.com/ionic-4-multiple-slides-on-single-view-using-swiper-slider/#more-1410

shally12 avatar Aug 24 '19 09:08 shally12