Created
September 5, 2022 07:40
-
-
Save nuhmanpk/787afa87847f334cb03ca1b9229b0737 to your computer and use it in GitHub Desktop.
AppModule
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<lib-ngx-image-zoom | |
[thumbImage]='imageUrl' [fullImage]=imageUrl maxZoomRatio="10" magnification="1" | |
enableScrollZoom="true" altText="img-not-found"> | |
</lib-ngx-image-zoom> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.css'], | |
}) | |
export class AppComponent implements OnInit { | |
imageUrl: string; | |
constructor() {} | |
ngOnInit() { | |
this.imageUrl="YOUR_URL_HERE" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Adding Range slider with +/- buttons | |
<div class="zoom-control" (click)="onDecrease()"> - </div> | |
<input type="range" min="1" max="10" step="1" value={{scaleRange}} class="form-range" | |
style="width: 200px; height: 50px;" #ref (change)="valueChanged(ref.value)"> | |
<div class="zoom-control" (click)="onIncrease()"> + </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div (mousewheel)="scroll(val)"> | |
<lib-ngx-image-zoom #val | |
[thumbImage]='imageUrl' [fullImage]=imageUrl maxZoomRatio="10" magnification="1" | |
enableScrollZoom="true" altText="img-not-found"> | |
</lib-ngx-image-zoom> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. | |
.. | |
... | |
scaleRange: number; | |
.... | |
.... | |
valueChanged(value: number) { | |
if (value === 1) { | |
this.scaleRange = 1; | |
} else { | |
this.scaleRange = value; | |
} | |
} | |
onDecrease() { | |
if (this.scaleRange <= 1) { | |
this.scaleRange = 1; | |
} else { | |
this.scaleRange = this.scaleRange - 1; | |
} | |
} | |
onIncrease() { | |
if (this.scaleRange >= 10) { | |
this.scaleRange = 10; | |
} else { | |
this.scaleRange = this.scaleRange + 1; | |
} | |
} | |
scroll(event) { | |
this.scaleRange = event.magnification; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { BrowserModule } from '@angular/platform-browser'; | |
import { NgModule } from '@angular/core'; | |
import { AppComponent } from './app.component'; | |
// Import the library | |
import { NgxImageZoomModule } from 'ngx-image-zoom'; | |
@NgModule({ | |
declarations: [ | |
AppComponent | |
], | |
imports: [ | |
BrowserModule, | |
NgxImageZoomModule // <-- Add this line | |
], | |
providers: [], | |
bootstrap: [AppComponent] | |
}) | |
export class AppModule { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment