Skip to content

Commit

Permalink
Migrate to standalone
Browse files Browse the repository at this point in the history
  • Loading branch information
PowerKiKi authored and Mawi137 committed May 8, 2024
1 parent 68b52f4 commit 76256a2
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 77 deletions.
31 changes: 6 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,6 @@ For a list of breaking changes and update instructions, go to [releases](https:/
Only Angular 16+ is supported.

### Example usage
Add the ImageCropperModule to the imports of the module which will be using the Image Cropper.
``` typescript
import { NgModule } from '@angular/core';
import { ImageCropperModule } from 'ngx-image-cropper';

@NgModule({
imports: [
...
ImageCropperModule
],
declarations: [
...
],
exports: [
...
],
providers: [
...
]
})
export class YourModule {
}
```

Add the element to your HTML:
``` html
Expand All @@ -53,11 +30,15 @@ Add the element to your HTML:
<img [src]="croppedImage" />
```

And add this to your ts file:
In your ts file, declare the usage of `ImageCropperComponent` and add the following methods:
``` typescript
import { ImageCroppedEvent, LoadedImage } from 'ngx-image-cropper';
import { ImageCropperComponent, ImageCroppedEvent, LoadedImage } from 'ngx-image-cropper';
import { DomSanitizer } from '@angular/platform-browser';

@Component({
standalone: true,
imports: [ImageCropperComponent]
})
export class YourComponent {
imageChangedEvent: any = '';
croppedImage: any = '';
Expand Down
8 changes: 6 additions & 2 deletions projects/demo-app/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { Component } from '@angular/core';
import { Dimensions, ImageCroppedEvent, ImageTransform } from 'ngx-image-cropper';
import { Dimensions, ImageCroppedEvent, ImageTransform, ImageCropperComponent } from 'ngx-image-cropper';
import { DomSanitizer } from '@angular/platform-browser';
import { NgIf } from '@angular/common';
import { FormsModule } from "@angular/forms";

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
styleUrls: ['./app.component.scss'],
standalone: true,
imports: [NgIf, FormsModule, ImageCropperComponent]
})
export class AppComponent {
imageChangedEvent: any = '';
Expand Down
24 changes: 0 additions & 24 deletions projects/demo-app/src/app/app.module.ts

This file was deleted.

18 changes: 12 additions & 6 deletions projects/demo-app/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
import {enableProdMode} from '@angular/core';
import {environment} from './environments/environment';
import {AppComponent} from './app/app.component';
import {bootstrapApplication, HAMMER_LOADER} from '@angular/platform-browser';

if (environment.production) {
enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule)
bootstrapApplication(AppComponent, {
providers: [
{
provide: HAMMER_LOADER,
useValue: () => import('hammerjs')
}
]
})
.catch(err => console.error(err));
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ import { HammerStatic } from '../utils/hammer.utils';
import { getEventForKey, getInvertedPositionForKey, getPositionForKey } from '../utils/keyboard.utils';
import { first, takeUntil } from 'rxjs/operators';
import { fromEvent, merge } from 'rxjs';
import { NgIf } from '@angular/common';

@Component({
selector: 'image-cropper',
templateUrl: './image-cropper.component.html',
styleUrls: ['./image-cropper.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [NgIf],
})
export class ImageCropperComponent implements OnChanges, OnInit {
private settings = new CropperSettings();
Expand Down
18 changes: 0 additions & 18 deletions projects/ngx-image-cropper/src/lib/image-cropper.module.ts

This file was deleted.

1 change: 0 additions & 1 deletion projects/ngx-image-cropper/src/public-api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export * from './lib/component/image-cropper.component';
export * from './lib/services/crop.service';
export * from './lib/services/load-image.service';
export * from './lib/image-cropper.module';
export * from './lib/interfaces';
export { base64ToFile } from './lib/utils/blob.utils';
export { resizeCanvas } from './lib/utils/resize.utils';

0 comments on commit 76256a2

Please sign in to comment.