0.0.5 • Published 3 years ago

ngx-image-comparison-slider v0.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

ngx-image-comparison-slider

Image comparison component with slider, for Angular.
See an example here.
Works on mobile too!

Table of contents

  1. Installing
  2. Usage
  3. Additional Options
  4. Examples
  5. Licence

Installing

  • Run npm install ngx-image-comparison-slider to install library.
  • Import NgxImageComparisonSliderModule to your AppModule (or any module of choice).
    import {NgxImageComparisonSliderModule} from 'ngx-image-comparison-slider';
    @NgModule({
      imports: [ NgxImageComparisonSliderModule ],
      ...
    })
    export class AppModule { }

Usage

Simply use <ngx-image-comparison-slider> component anywhere in your template.

    <h1>Example</h1>
    <ngx-image-comparison-slider 
      src1='https://www.w3schools.com/html/pic_trulli.jpg' 
      src2='https://www.w3schools.com/html/img_girl.jpg'>
    </ngx-image-comparison-slider>

See more examples here

Additional options

OptionTypeDefaultExplanation
src1stringnullSource of the first (left-side) image
src2stringnullSource of the second (right-side) image
startPos'leftBorder' 'middle' 'rightBorder' number'middle'Starting position for slider: Left, Centered, Right, or a number (measured from left, in px)
maxWidthnumber600Maximum Width of the component in px
maxHeightnumber400Maximum Height of the component in px
imageFit'cover' 'contain' 'fill''cover'Fit mode for images (using objectFit css property)
leftBordernumber0Left maximum for sliding (in px)
rightBordernumbersame as maxWidthRight maximum for sliding (measured from left, in px)
alt1string'sliderImage1'Alt (name) of the first (left-side) image
alt2string'sliderImage2'Alt (name) of the second (right-side) image
sliderWidthnumber5Width of the slider line (in px)
sliderColorstring (css collor)'whitesmoke'Color of the slider line
sliderShadowbooltrueShows or hides a slight shadow on the slider
sliderBallSizenumbersliderWidth * 4Radius of circle in the middle of slider line
sliderBallImageColor'black' 'white''black'Color of the icon image, inside of slider ball
showSliderBallbooltrueShow or hide slider ball
calcSliderBallDifbooltrueTake slider ball into consideration when calculating right and left borders for sliding
zIndexStartnumber1000Defines the base for z-index property of images and slider

Examples

Go ahead and experiment yourself on stackblitz!

Licence

The MIT License (MIT)

Copyright (c) 2021 Web-Ez LTD.

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago