GithubHelp home page GithubHelp logo

hkfoxok / angular2-image-popup Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vimalavinisha/angular2-image-popup

0.0 2.0 0.0 1.8 MB

Image popup directive for angular2

License: MIT License

TypeScript 37.21% CSS 37.21% HTML 14.60% JavaScript 10.98%

angular2-image-popup's Introduction

Angular2 image popup

The sources for this package are in (https://github.com/vimalavinisha/angular2-image-popup) repo. Please file issues and pull requests against this repo.

Demo Output

angular2-image-popup popup ##Usage node install npm install angular2-image-popup bower install bower install image-popup ###1.In index.html page include following css ###2.component file use like below import {Component} from '@angular/core'; import {ImageModal} from '../directives/angular2-image-popup/image-modal-popup'; @Component({ selector : 'my-app', directives: [ImageModal], template: `

Example - Default

you can directly access "ImageModel" directive for both listing thumbnails and popup images

        <ImageModal [modalImages]="images"></ImageModal>
        <h2>  Example with thumbnail pointers </h2>
        <p> you can list images in your file and then calling "ImageModel" directive to show images on popup only</p>
        <div *ngFor="let img of images; let i= index"> 
          <div class="float-left" *ngIf="i <= 2" >
            <a class="more" *ngIf="i==2" (click)="OpenImageModel(img.img,images)"> +{{images.length - 3}} more </a> 
            <img class="list-img" src="{{img.thumb}}"(click)="OpenImageModel(img.img,images)" alt='Image' />
          </div>
        </div>
        <div *ngIf="openModalWindow">
          <ImageModal [modalImages]="images" [imagePointer] = "imagePointer" (cancelEvent) ="cancelImageModel()"></ImageModal>
        </div>
    `    
  })
  export class AppComponent {
    openModalWindow:boolean=false;
    imagePointer:number;
    images = [
      { thumb: './app/assets/images/gallery/thumbs/img1.jpg', img: './app/assets/images/gallery/img1.jpg', description: 'Image 1' },
      { thumb: './app/assets/images/gallery/thumbs/img2.jpg', img: './app/assets/images/gallery/img2.jpg', description: 'Image 2' },
      { thumb: './app/assets/images/gallery/thumbs/img3.jpg', img: './app/assets/images/gallery/img3.jpg', description: 'Image 3' },
      { thumb: './app/assets/images/gallery/thumbs/img4.jpg', img: './app/assets/images/gallery/img4.jpg', description: 'Image 4' },
      { thumb: './app/assets/images/gallery/thumbs/img5.jpg', img: './app/assets/images/gallery/img5.jpg', description: 'Image 5' }
    ];
    constructor() {

    }
   OpenImageModel(imageSrc,images) {
     //alert('OpenImages');
     var imageModalPointer;
     for (var i = 0; i < images.length; i++) {
            if (imageSrc === images[i].img) {
              imageModalPointer = i;
              console.log('jhhl',i);
              break;
            }
       }
     this.openModalWindow = true;
     this.images = images;
     this.imagePointer  = imageModalPointer;
   }
   cancelImageModel() {
     this.openModalWindow = false;
   }
  }

angular2-image-popup's People

Contributors

vimalavinisha avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.