0.0.47 • Published 5 years ago

ng-ionic-connectedanim v0.0.47

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

Connected Animation for Ionic Framework

Easily add Connected Animation (in UWP) or Shared Element Transition (in Android) to your elements.

Example Project

Here is an example

Setup

  1. install via npm:
npm i ng-ionic-connectedanim@latest --save
  1. Import ConnectedAnimationModule in your module
import { ConnectedAnimationModule } from "ng-ionic-connectedanim";

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

Usage

1. Basic example. as easy as:

In Page1.html:

<img [src]="image" [animStart]="'animation-cover'">
<button (click)="push()">Push page2</button>

Page1.ts:

    push() {
        this.navCtrl.push('Page2');
    }

Page2.html:

<img [src]="image" [animEnd]="'animation-cover'">

2. Multiple connected animation

Page1.html:

<img [src]="image" [animStart]="'anim-image'">
<p class="title" [animStart]="'anim-title'">
<button (click)="push()">Push page2</button>

Page1.ts:

    push() {
        this.navCtrl.push('Page2');
    }

Page2.html:

<img [src]="image" [animEnd]="'anim-image'">
<p class="title" [animEnd]="'anim-title'">

Note: If you want to use any element other than img, the animStart element and animEnd must be identical in font-*, width, height and text-align, otherwise the animation will not work well.

3. Multiple Items as 'animStart'

Example 1

When you have a list of items in the first page, it is important to pass the element index before navigating to the second page, so animation can be played correctly. Also add animItem attribute to animated element.

Page1.html:

<div *ngFor="let item of items; let i = index" (click)="pushPage(i)">
    <img [src]="item.image" [animStart]="'animation-image'" animItem>
</div>

Pgae1.ts:

import {ConnectedAnimationService} from 'ng-ionic-connectedanim';
export class Page1 {
    constructor(private navCtrl: NavController,
                private connectedAnimationService: ConnectedAnimationService) {
    }

    pushPage(itemIndex) {
        // pass item index
        this.connectedAnimationService.setItemIndex(itemIndex, this);
        // then push page2
        this.navCtrl.push('Page2');
    }
}

Page2.html:

<img [src]="image" [animEnd]="'animation-image'">

4. Manually play animation:

This is useful for elements in the same page. set autoFire to false in animOptions:

<img [src]="image" [animStart]="'animation1'" [animOptions]="{ autoFire: false }">
<button (click)="openModal()">Open</button>

<div class="my-modal">
    <img [src]="image" [animEnd]="'animation1'">
    <button (click)="closeModal()">Close</button>
</div>
export class Page {
    constructor(private animationService: ConnectedAnimationService) {
    }

    openModal() {
        // first show your modal 
        // Make sure its 'style.display' is not 'none' before playing animation.


        //let itemIndex = 0; /* Send element index if you are using ngFor */
        this.animationService.playAnimations(this/*, itemIndex*/);
        // or play a specific animation by its name
        //this.animationService.playAnimation('animation1'/*, itemIndex*/);
    }

    closeModal() {
        this.animationService.playAnimationBack(this);
        // then hide the modal...
    }
}

Example 2

Options

You can pass animation options to `animStart' element.

<img [animStart]="'animation1'" [animOptions]="options">

Options:

OptionDesc.
autoFireSet autoFire to false to manually play the animation by calling animationService.playAnimation(), default is true.
typeAnimation type, e.g.: 'ease', 'ease-in'...
delayAnimation delay.
durationAnimation duration.
targetRectTarget element ('animEnd' element) position or offset.
0.0.47

5 years ago

0.0.46

6 years ago

0.0.45

6 years ago

0.0.44

6 years ago

0.0.43

6 years ago

0.0.42

6 years ago

0.0.41

6 years ago

0.0.40

6 years ago

0.0.39

6 years ago

0.0.38

6 years ago

0.0.37

6 years ago

0.0.36

6 years ago

0.0.35

6 years ago

0.0.34

6 years ago

0.0.33

6 years ago

0.0.32

6 years ago

0.0.31

6 years ago

0.0.30

6 years ago

0.0.29

6 years ago

0.0.28

6 years ago

0.0.27

6 years ago

0.0.26

6 years ago

0.0.25

6 years ago

0.0.24

6 years ago

0.0.23

6 years ago

0.0.22

6 years ago

0.0.21

6 years ago

0.0.20

6 years ago

0.0.19

6 years ago

0.0.18

6 years ago

0.0.17

6 years ago

0.0.16

6 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago