Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support angular 16 #253

Merged
merged 8 commits into from
May 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: add draggable example
  • Loading branch information
xieziyu committed May 19, 2023
commit 7ae6352b0fcfc661292ee13421b46b738da8ffcb
28 changes: 22 additions & 6 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
"style": "scss",
"skipTests": true
},
"@schematics/angular:service": {
"skipTests": true
}
},
"root": "",
Expand All @@ -23,7 +27,7 @@
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/angular2-draggable-demo",
"outputPath": "dist/docs",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": [
Expand Down Expand Up @@ -63,13 +67,13 @@
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
"maximumWarning": "6kb",
"maximumError": "10kb"
}
],
"outputHashing": "all"
Expand Down Expand Up @@ -136,6 +140,18 @@
},
"angular2-draggable": {
"projectType": "library",
"schematics": {
"@schematics/angular:component": {
"style": "scss",
"skipTests": true
},
"@schematics/angular:service": {
"skipTests": true
},
"@schematics/angular:directive": {
"skipTests": true
}
},
"root": "projects/angular2-draggable",
"sourceRoot": "projects/angular2-draggable/src",
"prefix": "lib",
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"@angular/router": "^16.0.0",
"@ant-design/icons-angular": "^15.0.0",
"ng-zorro-antd": "15.1.0",
"ngx-markdown": "^16.0.0",
"prismjs": "^1.29.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.13.0"
Expand All @@ -56,19 +58,20 @@
"eslint": "^8.40.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"html-loader": "^4.2.0",
"jasmine-core": "~4.6.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.0.0",
"ng-packagr": "^16.0.0",
"ngx-markdown": "^16.0.0",
"node-sass": "^8.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.8.8",
"prettier-eslint": "^15.0.1",
"prismjs": "^1.29.0",
"raw-loader": "^4.0.2",
"ts-node": "^10.9.1",
"typescript": "~5.0.2"
}
}
6 changes: 0 additions & 6 deletions src/app/menus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,5 @@ export const APP_MENUS: AppMenu[] = [
path: '/draggable',
icon: 'drag',
text: 'Draggable',
submenus: [
{
path: '/draggable/basic',
text: 'Basic',
},
],
},
];
14 changes: 14 additions & 0 deletions src/app/pages/demo-draggable/demo-draggable-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { DraggableLayoutComponent } from './draggable-layout/draggable-layout.component';

const routes: Routes = [
{ path: '', redirectTo: 'demo', pathMatch: 'full' },
{ path: 'demo', component: DraggableLayoutComponent },
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class DemoDraggableRoutingModule {}
12 changes: 10 additions & 2 deletions src/app/pages/demo-draggable/demo-draggable.module.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { SharedModule } from '../../shared/shared.module';
import { DemoDraggableRoutingModule } from './demo-draggable-routing.module';
import { DraggableBasicComponent } from './draggable-basic/draggable-basic.component';
import { DraggableLayoutComponent } from './draggable-layout/draggable-layout.component';
import { DraggableOptionsComponent } from './draggable-options/draggable-options.component';
import { DraggableEventsComponent } from './draggable-events/draggable-events.component';
import { DraggableBoundaryComponent } from './draggable-boundary/draggable-boundary.component';
import { DraggableMethodsComponent } from './draggable-methods/draggable-methods.component';

@NgModule({
declarations: [],
imports: [CommonModule],
declarations: [DraggableBasicComponent, DraggableLayoutComponent, DraggableOptionsComponent, DraggableEventsComponent, DraggableBoundaryComponent, DraggableMethodsComponent],
imports: [CommonModule, SharedModule, DemoDraggableRoutingModule],
})
export class DemoDraggableModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- DEMO START -->
<div ngDraggable class="drag-block-sm">Drag Me!</div>
<!-- DEMO END -->

<app-code-block [html]="html" [component]="component"></app-code-block>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Component } from '@angular/core';
// IGNORE START
declare const require: any;
// IGNORE END

@Component({
selector: 'app-draggable-basic',
templateUrl: './draggable-basic.component.html',
styleUrls: ['./draggable-basic.component.scss'],
})
export class DraggableBasicComponent {
// IGNORE START
html =
require('!!html-loader?{"minimize": {"removeComments":false,"caseSensitive":true}}!./draggable-basic.component.html')
.default;
component = require('!!raw-loader!./draggable-basic.component.ts').default;
// IGNORE END
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!-- DEMO START -->
<div nz-row [nzGutter]="4">
<div nz-col [nzSpan]="12">
<p>
<button (click)="inBounds = !inBounds" nz-button nzType="default">toggle [inBounds]</button>
</p>
<p>
<button (click)="outOfBounds('top')" nz-button nzType="default">
toggle [outOfBounds] top {{ myOutOfBounds.top ? ' (active)' : '' }}
</button>
</p>
<p>
<button (click)="outOfBounds('right')" nz-button nzType="default">
toggle [outOfBounds] right {{ myOutOfBounds.right ? ' (active)' : '' }}
</button>
</p>
<p>
<button (click)="outOfBounds('bottom')" nz-button nzType="default">
toggle [outOfBounds] bottom {{ myOutOfBounds.bottom ? ' (active)' : '' }}
</button>
</p>
<p>
<button (click)="outOfBounds('left')" nz-button nzType="default">
toggle [outOfBounds] left {{ myOutOfBounds.left ? ' (active)' : '' }}
</button>
</p>
</div>
<div nz-col [nzSpan]="12">
<div
class="drag-boundary"
[ngClass]="{
'top-b': !edge?.top,
'bottom-b': !edge?.bottom,
'left-b': !edge?.left,
'right-b': !edge?.right
}"
#myBounds>
<p class="label">#myBounds</p>
<div
ngDraggable
class="drag-block"
(edge)="checkEdge($event)"
[bounds]="myBounds"
[inBounds]="inBounds"
[outOfBounds]="myOutOfBounds">
<p>Drag me {{ inBounds ? 'in #myBounds' : '' }}</p>
<p>check your console</p>
</div>
</div>
</div>
</div>

<!-- DEMO END -->

<app-code-block [html]="html" [component]="component"></app-code-block>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Component } from '@angular/core';
// IGNORE START
declare const require: any;
// IGNORE END

@Component({
selector: 'app-draggable-boundary',
templateUrl: './draggable-boundary.component.html',
styleUrls: ['./draggable-boundary.component.scss'],
})
export class DraggableBoundaryComponent {
// IGNORE START
html =
require('!!html-loader?{"minimize": {"removeComments":false,"caseSensitive":true}}!./draggable-boundary.component.html')
.default;
component = require('!!raw-loader!./draggable-boundary.component.ts').default;
// IGNORE END
inBounds = true;
myOutOfBounds = {
top: false,
right: false,
bottom: false,
left: false,
};
edge = {
top: true,
bottom: true,
left: true,
right: true,
};

checkEdge(event) {
this.edge = event;
console.log('edge:', event);
}

outOfBounds(position) {
if (this.myOutOfBounds[position]) {
this.myOutOfBounds[position] = false;
} else {
this.myOutOfBounds[position] = true;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!-- DEMO START -->
<div nz-row [nzGutter]="6">
<div nz-col [nzSpan]="6">
<nz-alert
nzType="info"
nzMessage="
movingOffset: { x: {{ movingOffset.x }}, y: {{ movingOffset.y }} }
"></nz-alert>
</div>
<div nz-col [nzSpan]="6">
<nz-alert
nzType="info"
nzMessage="
endOffset: { x: {{ endOffset.x }}, y: {{ endOffset.y }} }
"></nz-alert>
</div>
</div>
<nz-divider></nz-divider>
<div
ngDraggable
class="drag-block"
[zIndex]="'1000'"
(started)="onStart($event)"
(stopped)="onStop($event)"
(movingOffset)="onMoving($event)"
[preventDefaultEvent]="true"
(endOffset)="onMoveEnd($event)">
<p>Drag me</p>
<p>check your console</p>
</div>
<!-- DEMO END -->

<app-code-block [html]="html" [component]="component"></app-code-block>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Component } from '@angular/core';
// IGNORE START
declare const require: any;
// IGNORE END

@Component({
selector: 'app-draggable-events',
templateUrl: './draggable-events.component.html',
styleUrls: ['./draggable-events.component.scss'],
})
export class DraggableEventsComponent {
// IGNORE START
html =
require('!!html-loader?{"minimize": {"removeComments":false,"caseSensitive":true}}!./draggable-events.component.html')
.default;
component = require('!!raw-loader!./draggable-events.component.ts').default;
// IGNORE END
movingOffset = { x: 0, y: 0 };
endOffset = { x: 0, y: 0 };

onStart(event) {
console.log('started output:', event);
}

onStop(event) {
console.log('stopped output:', event);
}

onMoving(event) {
this.movingOffset.x = event.x;
this.movingOffset.y = event.y;
}

onMoveEnd(event) {
this.endOffset.x = event.x;
this.endOffset.y = event.y;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<nz-page-header nzTitle="ngDraggable">
<nz-breadcrumb nz-page-header-breadcrumb>
<nz-breadcrumb-item>
<a routerLink="/welcome">Home</a>
</nz-breadcrumb-item>
<nz-breadcrumb-item>Draggable</nz-breadcrumb-item>
</nz-breadcrumb>
</nz-page-header>

<nz-divider></nz-divider>

<nz-tabset style="margin-top: 8px" [nzTabPosition]="'left'">
<nz-tab nzTitle="Basic Usage">
<ng-template nz-tab>
<app-draggable-basic></app-draggable-basic>
</ng-template>
</nz-tab>
<nz-tab nzTitle="Options">
<ng-template nz-tab>
<app-draggable-options></app-draggable-options>
</ng-template>
</nz-tab>
<nz-tab nzTitle="Events">
<ng-template nz-tab>
<app-draggable-events></app-draggable-events>
</ng-template>
</nz-tab>
<nz-tab nzTitle="Boundary">
<ng-template nz-tab>
<app-draggable-boundary></app-draggable-boundary>
</ng-template>
</nz-tab>
<nz-tab nzTitle="Methods">
<ng-template nz-tab>
<app-draggable-methods></app-draggable-methods>
</ng-template>
</nz-tab>
</nz-tabset>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-draggable-layout',
templateUrl: './draggable-layout.component.html',
styleUrls: ['./draggable-layout.component.scss'],
})
export class DraggableLayoutComponent {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- DEMO START -->
<div nz-row [nzGutter]="6">
<div nz-col [nzSpan]="6">
<button (click)="block.resetPosition()" nz-button nzType="default">.resetPosition()</button>
</div>
</div>
<nz-divider></nz-divider>
<div ngDraggable #block="ngDraggable" class="drag-block-sm">Drag Me!</div>
<!-- DEMO END -->

<app-code-block [html]="html" [component]="component"></app-code-block>
Loading