ngx-image-hero
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

angular 9+ image-hero

npm version NPM monthly downloads NPM total downloads License: MIT Issues Web Demo

Demo Website

Table of contents

About

A package to implement hero animations, allowing users to click on images and smoothly zoom them into a larger, immersive view, enhancing the user experience and interaction with images.

Getting started

Installation

npm install ngx-image-hero

Standalone component

import { Component } from '@angular/core';
import { NgxImageHeroModule } from 'ngx-image-hero';

@Component({
  selector: 'app-root',
  standalone: true,
  templateUrl: './app.component.html',
  styleUrl: './app.component.scss',
  imports: [ NgxImageHeroModule ],
})
export class AppComponent {}

Or for Module

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';

import { NgxImageHeroModule } from 'ngx-image-hero';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    NgxImageHeroModule,
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

Documentation

Inputs

Option Type Default Comment
highQualityPath string The path to the high-quality image or content to be displayed, which seamlessly replaces the current picture when opened.
fixedHero boolean false Specifies whether to use the fixed-hero mode when absolute positioning is not effective due to overflow issues.
supportedFormats string[] An array of supported image formats, which is only required when using the <picture> element where the browser automatically selects the format.
browserSupportAvif boolean If you have already manually determined whether the browser supports AVIF, you can set it using this option. Otherwise, the package will automatically perform the check. This option is only required when supportedFormats contains values.
browserSupportWebP boolean If you have already manually determined whether the browser supports WebP, you can set it using this option. Otherwise, the package will automatically perform the check. This option is only required when supportedFormats contains values.

Outputs

Option Type Comment
openHero EventEmitter<void> Triggered when the hero animation starts.
closeHero EventEmitter<void> Triggered when the hero animation ends.

Example

Simple example

<img ngxHero src="https://picsum.photos/id/200/400" alt="demo-image" />

Complete example demonstrating all properties

<picture>
  @for (format of imgFormats; track format) {
  <source srcset="assets/img/demo.{{format}}" type="image/{{ format }}" />
  }
  <img
    ngxHero
    fixedHero="false"
    highQualityPath="assets/img/demo_4x"
    browserSupportAvif="supportAvif"
    browserSupportWebP="supportWebP"
    [supportedFormats]="['avif', 'webp', 'jpeg']"
    (openHero)="onOpenHero()"
    (closeHero)="onCloseHero()"
    src="assets/img/demo.jpeg"
    alt="demo-image"
  />
</picture>

Contributing

I welcome contributions from the open-source community to make this project even better. Whether you want to report a bug, suggest a new feature, or contribute code, I appreciate your help.

Bug Reports and Feature Requests

If you encounter a bug or have an idea for a new feature, please open an issue on my GitHub Issues page. I will review it and discuss the best approach to address it.

Code Contributions

If you'd like to contribute code to this project, please follow these steps:

  1. Fork the repository to your GitHub account.
  2. Clone your forked repository to your local machine.
git clone https://github.com/hm21/ngx-scroll-animations.git

Package Sidebar

Install

npm i ngx-image-hero

Weekly Downloads

9

Version

1.0.8

License

MIT

Unpacked Size

151 kB

Total Files

22

Last publish

Collaborators

  • hm21