├── .gitignore
├── .npmignore
├── CHANGELOG.md
├── LICENSE.md
├── README.md
├── app-screenshot.png
├── package.json
├── src
├── index.ts
├── zoom-area.component.ts
├── zoom-area.module.ts
├── zoom-area.provider.ts
└── zoom-area.scss
└── tsconfig.json
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 | aot
4 | .idea
5 | .DS_STORE
6 | .DX_STORE
7 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | src
2 | node_modules
3 | .gitignore
4 | .npmignore
5 | tsconfig.json
6 | .idea
7 | aot
8 | app-screenshot.png
9 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 |
2 | ## 1.0.17 (2019-04-22)
3 |
4 | ### Feature
5 |
6 | * **New version:**
7 | Introduces the features to release a new version for a Ionic 4.
8 |
9 |
10 | ## 1.0.16 (2018-03-26)
11 |
12 | ### Bug Fixes
13 |
14 | * **AOT Compilation:**
15 | [#10](https://github.com/leonardosalles/ionic2-zoom-area/issues/10) - Fixes the problem during --prod build with Ionic.
16 |
17 |
18 | ## 1.0.12 (2017-11-28)
19 |
20 | ### Bug Fixes
21 |
22 | * **Known Issue:**
23 | It fixes a known issue that prevent user to start vertical pan.
24 |
25 |
26 | ## 1.0.11 (2017-11-23)
27 |
28 | ### Bug Fixes
29 |
30 | * **LazyLoading:**
31 | Closes [#8](https://github.com/leonardosalles/ionic2-zoom-area/issues/8) - Fix ZoomAreaProvider not available
32 |
33 |
34 | ## 1.0.10 (2017-11-23)
35 |
36 | ### Bug Fixes
37 |
38 | * **LazyLoading:**
39 | Closes [#6](https://github.com/leonardosalles/ionic2-zoom-area/issues/6) - Allow module to be used with LazyLoading
40 |
41 | * **Feature Request:**
42 | Closes [#2](https://github.com/leonardosalles/ionic2-zoom-area/issues/2) - Add support to set center if zoom scale is greater than 1
43 |
44 |
45 |
46 | ## 1.0.9 (2017-10-17)
47 | Release the kraken
48 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Leonardo Salles
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://www.npmjs.com/package/ionic2-zoom-area)
2 | [](https://www.npmjs.com/package/ionic2-zoom-area)
3 | [](https://www.npmjs.com/package/ionic2-zoom-area)
4 |
5 | # A zoom area for Ionic 2 and 3 :)
6 |
7 | IMPORTANT: New release for Ionic 4 will be release here as a new Version of the core component.
8 |
9 | IMPORTANT: Versions 1.0.12 and 1.0.13 will not work as expected, please use <=1.0.11 or >=1.0.14 instead.
10 |
11 | A zoom area component with pinch support to zoom any element in page
12 |
13 | To see this in action, checkout the [example project here](https://github.com/leonardosalles/ionic2-zoom-area-example).
14 |
15 | IMPORTANT: This module requires Angular Animations and should be included in the app module.
16 |
17 |
18 |
19 | 
20 |
21 |
22 |
45 |
46 | # Installation
47 | ## Add Angular Animations
48 | ```shell
49 | npm i --save @angular/animations
50 | ```
51 |
52 | ## Import BrowserAnimationsModule in your app's module(s)
53 | ```ts
54 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
55 | ```
56 |
57 | And then
58 |
59 | ```ts
60 | imports: [
61 | ...
62 | BrowserAnimationsModule,
63 | ...
64 | ]
65 | ```
66 |
67 | ## Install the module via NPM
68 | ```shell
69 | npm i --save ionic2-zoom-area
70 | ```
71 |
72 | ## Import it in your app's module(s)
73 |
74 | Import `ZoomAreaModule.forRoot()` in your app's main module
75 |
76 | ```ts
77 | import { ZoomAreaModule } from 'ionic2-zoom-area';
78 |
79 | @NgModule({
80 | ...
81 | imports: [
82 | ...
83 | ZoomAreaModule.forRoot()
84 | ],
85 | ...
86 | })
87 | export class AppModule {}
88 | ```
89 |
90 | If your app uses lazy loading, you need to import `ZoomAreaModule` in your shared module or child modules:
91 | ```ts
92 | import { ZoomAreaModule } from 'ionic2-zoom-area';
93 |
94 | @NgModule({
95 | ...
96 | imports: [
97 | ...
98 | ZoomAreaModule
99 | ],
100 | ...
101 | })
102 | export class SharedModule {}
103 | ```
104 |
105 |
106 |
107 | # Usage
108 |
109 |
110 | ## `zoom-area` Component
111 |
112 | ### Inputs
113 |
114 | #### scale
115 | _(optional)_ _(two-way)_ The scale of your initial zoom. Defaults to `1`.
116 |
117 | #### controls
118 | _(optional)_ _(two-way)_ It allow you to hide or show zoom controls. Defaults to `true`.
119 |
120 |
121 | ### Outputs
122 |
123 | #### `afterZoomIn`
124 | Listen to this event to be notified when the user interact with zoom in.
125 |
126 | #### `afterZoomOut`
127 | Listen to this event to be notified when the user interact with zoom out.
128 |
129 |
130 |
131 | ## `ZoomAreaProvider` Provider
132 |
133 | ### notifyScroll
134 | ```ts
135 | notifyScroll(): void
136 | ```
137 | It broadcast an event when user scroll content inside zoom area.
138 |
139 | ### onScroll$
140 | ```ts
141 | onScroll$: Observable
142 | ```
143 | It allows you to listen for a scroll event inside your zoom area. You can use it to collapse you header for example.
144 |
145 | ```ts
146 | this.zoomAreaProvider.onScroll$.subscribe(state => {
147 | if (state === this.zoomAreaProvider.SCROLL_STATE.COLLAPSED) {
148 | console.log('Hide header');
149 | }
150 |
151 | if (state === this.zoomAreaProvider.SCROLL_STATE.EXPANDED) {
152 | console.log('Show header');
153 | }
154 | });
155 | ```
156 |
157 | ### scrollState$
158 | ```ts
159 | scrollState$: Observable
160 | ```
161 | It allows you to listen for a change in scroll state.
162 | ```ts
163 | this.zoomAreaProvider.scrollState$.subscribe(state => {
164 | console.log('Do whatever you want when scrollState change');
165 | });
166 | ```
167 |
168 | ### setCenter (x: number, y: number)
169 | ```ts
170 | setCenter: Function
171 | ```
172 | It allows you to change the position of the zoom manually if zoom scale is greather than 1.
173 | ```ts
174 | this.zoomAreaProvider.setCenter(x, y);
175 | this.zoomAreaProvider.setCenter(20, 50);
176 | ```
177 |
178 | # Examples
179 |
180 | ## Basic example
181 |
182 | ## Example with methods
183 | ```html
184 |
185 |
Zoom It
186 | or
187 |
188 |
189 | ```
190 |
191 |
192 |
193 | ## Known Issues 🤬
194 | - ✅(Fixed in 1.0.12) Vertical pan is in conflict with scroll event and are not fired like horizontal pan.
195 |
196 |
197 |
198 |
199 |
200 | ## Roadmap
201 | - ✅(Fixed in 1.0.10) - Add support to move center of zoom
202 |
203 |
204 | ## Contribution
205 | - **Having an issue**? or looking for support? [Open an issue](https://github.com/leonardosalles/ionic2-zoom-area/issues/new) and we will get you the help you need.
206 | - Got a **new feature or a bug fix**? Fork the repo, make your changes, and submit a pull request.
207 |
208 | ## Support this project
209 | If you find this project useful, please star the repo to let people know that it's reliable. Also, share it with friends and colleagues that might find this useful as well. Thank you :smile:
210 |
211 | ## Special Thanks ##
212 | We would like to thank [JetBrains](http://www.jetbrains.com) for supporting this project by offering open-source license of their [IntelliJ IDE](http://www.jetbrains.com/idea/) to us.
213 |
--------------------------------------------------------------------------------
/app-screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonardosalles/ionic2-zoom-area/f2f31b77e9efc936df53a9b6c3b806537caa8b0a/app-screenshot.png
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ionic2-zoom-area",
3 | "version": "1.0.16",
4 | "description": "A zoom area component with pinch and pan support.",
5 | "main": "dist/index.js",
6 | "typings": "dist/index.d.ts",
7 | "scripts": {
8 | "build": "rm -rf aot dist && ngc",
9 | "postbuild": "npm run copy:scss",
10 | "copy:scss": "cp src/zoom-area.scss dist/",
11 | "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
12 | "postchangelog": "git commit -am \"chore(): update changelog\"",
13 | "shipit": "npm run build && npm publish"
14 | },
15 | "author": "Leonardo Salles ",
16 | "license": "MIT",
17 | "repository": "https://github.com/leonardosalles/ionic2-zoom-area",
18 | "dependencies": {
19 | "@angular/animations": "5.1.3",
20 | "@angular/common": "5.1.3",
21 | "@angular/compiler": "5.1.3",
22 | "@angular/compiler-cli": "5.1.3",
23 | "@angular/core": "10.2.5",
24 | "@angular/forms": "5.1.3",
25 | "@angular/http": "5.1.3",
26 | "@angular/platform-browser": "5.1.3",
27 | "@angular/platform-browser-dynamic": "5.1.3",
28 | "conventional-changelog-cli": "^1.3.4",
29 | "ionicons": "3.0.0",
30 | "rxjs": "5.5.2",
31 | "zone.js": "0.8.18",
32 | "ionic-angular": "3.9.2"
33 | },
34 | "devDependencies": {
35 | "typescript": "2.5.2"
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './zoom-area.component';
2 | export * from './zoom-area.provider';
3 | export * from './zoom-area.module';
--------------------------------------------------------------------------------
/src/zoom-area.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, ViewChild, Input, Output, EventEmitter, OnChanges, SimpleChanges } from '@angular/core';
2 | import { trigger, state, style, transition, animate } from '@angular/animations';
3 | import { Gesture, Content, RootNode } from 'ionic-angular';
4 | import { ZoomAreaProvider } from './zoom-area.provider';
5 |
6 | @Component({
7 | selector: 'zoom-area',
8 | template: `
9 |
10 |