1.1.0 • Published 5 years ago

ngx-floating-img v1.1.0

Weekly downloads
89
License
MIT
Repository
github
Last release
5 years ago

Floating Image Viewer

Mobile look and feel image viewer for Angular 6+

Website: https://qumhieh.github.io/ngx-floating-img/

NGXFloatingImg Demo GIF

Table of contents

Installation

Add ngx-floating-img to your Angular project

npm install --save ngx-floating-img

Once installed import NgxFloatingImgModule.forRoot() in your app.module.ts

import { NgxFloatingImgModule } from "ngx-floating-img";

...
@NgModule({
   ...
   imports: [
    ...
    NgxFloatingImgModule.forRoot(),
    ...
   ],
   ...
})
export class AppModule {}

NgxFloatingImgModule.forChild() for lazy loaded modules

NgxFloatingImgModule.forChild()

Add ngx-floating-img in your template file

<ngx-floating-img ... [options] ... >
    <img src="thumbImgSrc" />
</ngx-floating-img>

Options

OptionDescriptionTypeDefault
idComponent id, can be used as a return value in events handlingstring-
imgSrcFull image srcstring-
imgWidth ( Required )Full image width in pixels, if full image not provided then thumb image widthnumber-
imgHeight ( Required )Full image height in pixels, if full image not provided then thumb image heightnumber-
imgAnimationTypeImage animation type on show and hideany valid css animation (linear, ease-in ...)ease-out
imgAnimationSpeedImage animation speed on show and hideany number between 0 (for no animation) and 800250
vpPaddingViewport padding in pixels when full image is visiblenumber20
overlayColorImage overlay background colorcolortransparent
overlayAnimationEnable / disable fade animation for image overlaybooleantrue
overlayDismissEnable / disable close image on overlay clickbooleantrue
thumbBgColorThumb background colorcolor#f0f0f0
showLoadingEnable / disable loading barbooleantrue
loadingColorChange loading bar background colorcolortransparent
showCloseButtonShow / hide close buttonbooleantrue
disableScrollEnable / Disable page scrolling for desktop browsers only, as it's always disabled for mobile platform to meet the mobile experiencebooleanfalse

Default options

Default options can be changed by adding a new object of type NGXFloatingImgOptions when importing NgxFloatingImgModule in your module

NgxFloatingImgModule.forRoot({ imgAnimationSpeed: 200, vpPadding: 30, imgAnimationType: 'linear' })

NGXFloatingImgOptions default values

{
    showLoading: true
    loadingColor: transparent
    imgAnimationType: 'ease-out'
    imgAnimationSpeed: 250
    overlayColor: 'transparent'
    overlayAnimation: true
    overlayDismiss: true
    thumbBgColor: '#f0f0f0'
    vpPadding: 20
    showCloseButton: true
    disableScroll: false
}

Events

EventDescriptionReturn
beforeShowThis event fires right after thumb click and before animation startscomponent id
afterShowThis event fires after show animation is fully completedcomponent id
onFullImgLoadThis event fires after full image is fully loaded (if imgSrc attribute provided)component id
beforeCloseThis event fires right before close full image process startscomponent id
afterCloseThis event fires after closing animation completedcomponent id

Examples

https://qumhieh.github.io/ngx-floating-img/examples

Compatibility

- Tested on desktop versions of Chrome, Firefox, Safari, IE10+, Edge.
- Tested on Android and iPhone modern browsers.
- Tested on Ionic 4.

Change log

1.1.0
- Added disableScroll option.
- Improved the user experience on mobile devices.

Bugs

You can report any bugs as Github issues

License

The project is licensed under the MIT license