Giter VIP home page Giter VIP logo

image-comparison's Introduction

Angular 2+ Responsive Image Comparison Slider

Just a beauty and responsive plug and play image comparator module for Angular 2+.

You can use it to compare two different images, like before and after models.

Installing

Just download or clone this repository and save the src/app/modules/image-comparison folder into your angular project (in your modules folder, if you're following Angular Folder Structure patterns).

Import the Comparison Module into the module that declares the component where the Image Comparison will be applied.

import { myComponent } from './my.component'
import { ComparisonModule } from './modules/image-comparison/image-comparison.module'
 
@NgModule({
 	declarations: [myComponent]
	imports: [ComparisonModule]
})

Now, in your component, define a property with the URLs of the images to be compared into a list. It must have two values, obviously. See:

 public images: string[] = [
	 '/assets/image/image1.jpg',
	 '/assets/image/image2.jpg',
 ]

Note: The images must to have exactly the same dimensions (width and height) to works fine, dude.

Then insert the as-image-comparison element in the HTML of your component, just like this:

 <app-image-comparison *ngIf='images' [images]='images'></app-image-comparison>

Note: Is important to put the condition *ngIf='images' to avoid errors if the images have undefined values.

Options

Option Type Description
images string[] Array containing two items, each one as the URL of an image.
maxHeight (optional) number | string Defines a max height for the comparator stage. If number, it's calculated in pixels. If string, you can use px or vh unities.

Demo

After all, this must works like this:

See the live demo on https://chelvis.github.io/image-comparison/.

image-comparison's People

Contributors

chelvis avatar

Stargazers

lvyhe avatar Basilius Bias Astho Christyono avatar  avatar AXeL avatar Marcin Zabłocki avatar Pierre-Étienne Lord avatar Vlad Dumbrava avatar Nurlan avatar Behshad Ghorbani avatar

Watchers

James Cloos 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.