migrated protractor to cypress

This commit is contained in:
Konstantin Schütte 2022-02-07 12:52:32 +01:00
parent 0a38b8dfd4
commit ca85b6872a
24 changed files with 2354 additions and 2259 deletions

View file

@ -4,7 +4,7 @@ root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

View file

@ -1,6 +1,6 @@
{
"bracketSpacing": true,
"tabWidth": 2,
"tabWidth": 4,
"singleQuote": true,
"semi": true,
"useTabs": false,

View file

@ -105,7 +105,7 @@
"tsConfig": [
"tsconfig.app.json",
"tsconfig.spec.json",
"e2e/tsconfig.json"
"cypress/tsconfig.json"
],
"exclude": [
"**/node_modules/**"
@ -113,9 +113,21 @@
}
},
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"builder": "@cypress/schematic:cypress",
"options": {
"devServerTarget": "ivypinchApp:serve",
"watch": true,
"headless": false
},
"configurations": {
"production": {
"devServerTarget": "ivypinchApp:serve:production"
}
}
},
"cypress-run": {
"builder": "@cypress/schematic:cypress",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "ivypinchApp:serve"
},
"configurations": {
@ -123,6 +135,13 @@
"devServerTarget": "ivypinchApp:serve:production"
}
}
},
"cypress-open": {
"builder": "@cypress/schematic:cypress",
"options": {
"watch": true,
"headless": false
}
}
}
},
@ -157,15 +176,49 @@
"options": {
"tsConfig": [
"projects/ngx-pinch-zoom/tsconfig.lib.json",
"projects/ngx-pinch-zoom/tsconfig.spec.json"
"projects/ngx-pinch-zoom/tsconfig.spec.json",
"projects/ngx-pinch-zoom/cypress/tsconfig.json"
],
"exclude": [
"**/node_modules/**"
]
}
},
"cypress-run": {
"builder": "@cypress/schematic:cypress",
"options": {
"devServerTarget": "ngx-pinch-zoom:serve",
"configFile": "projects/ngx-pinch-zoom/cypress.json"
},
"configurations": {
"production": {
"devServerTarget": "ngx-pinch-zoom:serve:production"
}
}
},
"cypress-open": {
"builder": "@cypress/schematic:cypress",
"options": {
"watch": true,
"headless": false,
"configFile": "projects/ngx-pinch-zoom/cypress.json"
}
},
"e2e": {
"builder": "@cypress/schematic:cypress",
"options": {
"devServerTarget": "ngx-pinch-zoom:serve",
"watch": true,
"headless": false
},
"configurations": {
"production": {
"devServerTarget": "ngx-pinch-zoom:serve:production"
}
}
}
}
}
},
"defaultProject": "ivypinchApp"
}
}

9
cypress.json Normal file
View file

@ -0,0 +1,9 @@
{
"integrationFolder": "cypress/integration",
"supportFile": "cypress/support/index.ts",
"videosFolder": "cypress/videos",
"screenshotsFolder": "cypress/screenshots",
"pluginsFile": "cypress/plugins/index.ts",
"fixturesFolder": "cypress/fixtures",
"baseUrl": "http://localhost:4200"
}

View file

@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}

View file

@ -0,0 +1,18 @@
Cypress.on('window:before:load', (win) => {
cy.spy(win.console, 'error');
cy.spy(win.console, 'warn');
});
describe('workspace-project App', () => {
afterEach(() => {
cy.window().then((win) => {
expect(win.console.error).to.have.callCount(0);
expect(win.console.warn).to.have.callCount(0);
});
});
it('should display welcome message', () => {
cy.visit('/');
cy.get('title').should('contain.text', 'IvypinchApp');
});
});

3
cypress/plugins/index.ts Normal file
View file

@ -0,0 +1,3 @@
// Plugins enable you to tap into, modify, or extend the internal behavior of Cypress
// For more info, visit https://on.cypress.io/plugins-api
module.exports = (on, config) => {}

View file

@ -0,0 +1,43 @@
// ***********************************************
// This example namespace declaration will help
// with Intellisense and code completion in your
// IDE or Text Editor.
// ***********************************************
// declare namespace Cypress {
// interface Chainable<Subject = any> {
// customCommand(param: any): typeof customCommand;
// }
// }
//
// function customCommand(param: any): void {
// console.warn(param);
// }
//
// NOTE: You can use it like so:
// Cypress.Commands.add('customCommand', customCommand);
//
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

17
cypress/support/index.ts Normal file
View file

@ -0,0 +1,17 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// When a command from ./commands is ready to use, import with `import './commands'` syntax
// import './commands';

8
cypress/tsconfig.json Normal file
View file

@ -0,0 +1,8 @@
{
"extends": "../tsconfig.json",
"include": ["**/*.ts"],
"compilerOptions": {
"sourceMap": false,
"types": ["cypress", "node"]
}
}

View file

@ -1,37 +0,0 @@
// @ts-check
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter, StacktraceOption } = require('jasmine-spec-reporter');
/**
* @type { import("protractor").Config }
*/
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./src/**/*.e2e-spec.ts'
],
capabilities: {
browserName: 'chrome'
},
directConnect: true,
SELENIUM_PROMISE_MANAGER: false,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.json')
});
jasmine.getEnv().addReporter(new SpecReporter({
spec: {
displayStacktrace: StacktraceOption.PRETTY
}
}));
}
};

View file

@ -1,23 +0,0 @@
import { browser, logging } from 'protractor';
import { AppPage } from './app.po';
describe('workspace-project App', () => {
let page: AppPage;
beforeEach(() => {
page = new AppPage();
});
it('should display welcome message', async () => {
await page.navigateTo();
expect(await page.getTitleText()).toEqual('ivypinchApp app is running!');
});
afterEach(async () => {
// Assert that there are no errors emitted from the browser
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
expect(logs).not.toContain(jasmine.objectContaining({
level: logging.Level.SEVERE,
} as logging.Entry));
});
});

View file

@ -1,11 +0,0 @@
import { browser, by, element } from 'protractor';
export class AppPage {
async navigateTo(): Promise<unknown> {
return browser.get(browser.baseUrl);
}
async getTitleText(): Promise<string> {
return element(by.css('app-root .content span')).getText();
}
}

View file

@ -1,13 +0,0 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/e2e",
"module": "commonjs",
"target": "es2018",
"types": [
"jasmine",
"node"
]
}
}

3676
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -7,7 +7,9 @@
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
"e2e": "ng e2e",
"cypress:open": "cypress open",
"cypress:run": "cypress run"
},
"dependencies": {
"@angular/animations": "~13.2.1",
@ -29,10 +31,12 @@
"@angular-eslint/eslint-plugin-template": "^13.0.1",
"@angular/cli": "~13.2.2",
"@angular/compiler-cli": "~13.2.1",
"@cypress/schematic": "^1.6.0",
"@types/jasmine": "~3.10.3",
"@types/node": "^17.0.15",
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"cypress": "latest",
"eslint": "^8.8.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jsdoc": "^37.7.1",
@ -45,7 +49,6 @@
"karma-jasmine": "~4.0.1",
"karma-jasmine-html-reporter": "^1.7.0",
"ng-packagr": "^13.2.1",
"protractor": "~7.0.0",
"ts-node": "~10.4.0",
"typescript": "~4.5.5"
}

View file

@ -0,0 +1,9 @@
{
"integrationFolder": "projects/ngx-pinch-zoom/cypress/integration",
"supportFile": "projects/ngx-pinch-zoom/cypress/support/index.ts",
"videosFolder": "projects/ngx-pinch-zoom/cypress/videos",
"screenshotsFolder": "projects/ngx-pinch-zoom/cypress/screenshots",
"pluginsFile": "projects/ngx-pinch-zoom/cypress/plugins/index.ts",
"fixturesFolder": "projects/ngx-pinch-zoom/cypress/fixtures",
"baseUrl": "http://localhost:4200"
}

View file

@ -0,0 +1,7 @@
describe('My First Test', () => {
it('Visits the initial project page', () => {
cy.visit('/')
cy.contains('Welcome')
cy.contains('sandbox app is running!')
})
})

View file

@ -0,0 +1,3 @@
// Plugins enable you to tap into, modify, or extend the internal behavior of Cypress
// For more info, visit https://on.cypress.io/plugins-api
module.exports = (on, config) => {}

View file

@ -0,0 +1,43 @@
// ***********************************************
// This example namespace declaration will help
// with Intellisense and code completion in your
// IDE or Text Editor.
// ***********************************************
// declare namespace Cypress {
// interface Chainable<Subject = any> {
// customCommand(param: any): typeof customCommand;
// }
// }
//
// function customCommand(param: any): void {
// console.warn(param);
// }
//
// NOTE: You can use it like so:
// Cypress.Commands.add('customCommand', customCommand);
//
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

View file

@ -0,0 +1,17 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// When a command from ./commands is ready to use, import with `import './commands'` syntax
// import './commands';

View file

@ -0,0 +1,8 @@
{
"extends": "../../../tsconfig.json",
"include": ["**/*.ts"],
"compilerOptions": {
"sourceMap": false,
"types": ["cypress", "node"]
}
}

View file

@ -5,293 +5,305 @@ import { defaultProperties, backwardCompatibilityProperties } from './properties
import { IvyPinch } from './ivypinch';
interface ComponentProperties extends Properties {
disabled?: boolean;
overflow?: 'hidden' | 'visible';
disableZoomControl?: 'disable' | 'never' | 'auto';
backgroundColor?: string;
disabled?: boolean;
overflow?: 'hidden' | 'visible';
disableZoomControl?: 'disable' | 'never' | 'auto';
backgroundColor?: string;
}
export const _defaultComponentProperties: ComponentProperties = {
overflow: 'hidden',
disableZoomControl: 'auto',
backgroundColor: 'rgba(0,0,0,0.85)',
overflow: 'hidden',
disableZoomControl: 'auto',
backgroundColor: 'rgba(0,0,0,0.85)',
};
type PropertyName = keyof ComponentProperties;
@Component({
selector: 'pinch-zoom, [pinch-zoom]',
exportAs: 'pinchZoom',
templateUrl: './pinch-zoom.component.html',
styleUrls: ['./pinch-zoom.component.sass'],
selector: 'pinch-zoom, [pinch-zoom]',
exportAs: 'pinchZoom',
templateUrl: './pinch-zoom.component.html',
styleUrls: ['./pinch-zoom.component.sass'],
})
export class PinchZoomComponent implements OnDestroy {
pinchZoom: any;
_properties!: ComponentProperties;
defaultComponentProperties!: ComponentProperties;
zoomControlPositionClass: string | undefined;
_transitionDuration!: number;
_doubleTap!: boolean;
_doubleTapScale!: number;
_autoZoomOut!: boolean;
_limitZoom!: number | 'original image size';
pinchZoom: any;
_properties!: ComponentProperties;
defaultComponentProperties!: ComponentProperties;
zoomControlPositionClass: string | undefined;
_transitionDuration!: number;
_doubleTap!: boolean;
_doubleTapScale!: number;
_autoZoomOut!: boolean;
_limitZoom!: number | 'original image size';
@Input('properties') set properties(value: ComponentProperties) {
if (value) {
this._properties = value;
}
}
get properties() {
return this._properties;
}
// transitionDuration
@Input('transition-duration') set transitionDurationBackwardCompatibility(value: number) {
if (value) {
this._transitionDuration = value;
}
}
@Input('transitionDuration') set transitionDuration(value: number) {
if (value) {
this._transitionDuration = value;
}
}
get transitionDuration() {
return this._transitionDuration;
}
// doubleTap
@Input('double-tap') set doubleTapBackwardCompatibility(value: boolean) {
if (value) {
this._doubleTap = value;
}
}
@Input('doubleTap') set doubleTap(value: boolean) {
if (value) {
this._doubleTap = value;
}
}
get doubleTap() {
return this._doubleTap;
}
// doubleTapScale
@Input('double-tap-scale') set doubleTapScaleBackwardCompatibility(value: number) {
if (value) {
this._doubleTapScale = value;
}
}
@Input('doubleTapScale') set doubleTapScale(value: number) {
if (value) {
this._doubleTapScale = value;
}
}
get doubleTapScale() {
return this._doubleTapScale;
}
// autoZoomOut
@Input('auto-zoom-out') set autoZoomOutBackwardCompatibility(value: boolean) {
if (value) {
this._autoZoomOut = value;
}
}
@Input('autoZoomOut') set autoZoomOut(value: boolean) {
if (value) {
this._autoZoomOut = value;
}
}
get autoZoomOut() {
return this._autoZoomOut;
}
// limitZoom
@Input('limit-zoom') set limitZoomBackwardCompatibility(value: number | 'original image size') {
if (value) {
this._limitZoom = value;
}
}
@Input('limitZoom') set limitZoom(value: number | 'original image size') {
if (value) {
this._limitZoom = value;
}
}
get limitZoom() {
return this._limitZoom;
}
@Input() disabled!: boolean;
@Input() disablePan!: boolean;
@Input() overflow!: 'hidden' | 'visible';
@Input() zoomControlScale!: number;
@Input() disableZoomControl!: 'disable' | 'never' | 'auto';
@Input() backgroundColor!: string;
@Input() limitPan!: boolean;
@Input() minPanScale!: number;
@Input() minScale!: number;
@Input() listeners!: 'auto' | 'mouse and touch';
@Input() wheel!: boolean;
@Input() autoHeight!: boolean;
@Input() wheelZoomFactor!: number;
@Input() draggableImage!: boolean;
@HostBinding('style.overflow')
get hostOverflow() {
return this.properties['overflow'];
}
@HostBinding('style.background-color')
get hostBackgroundColor() {
return this.properties['backgroundColor'];
}
get isTouchScreen() {
var prefixes = ' -webkit- -moz- -o- -ms- '.split(' ');
var mq = function (query: any) {
return window.matchMedia(query).matches;
};
if ('ontouchstart' in window) {
return true;
@Input('properties') set properties(value: ComponentProperties) {
if (value) {
this._properties = value;
}
}
// include the 'heartz' as a way to have a non matching MQ to help terminate the join
// https://git.io/vznFH
var query = ['(', prefixes.join('touch-enabled),('), 'heartz', ')'].join('');
return mq(query);
}
get isDragging() {
return this.pinchZoom ? this.pinchZoom.isDragging() : undefined;
}
get isDisabled() {
return this.properties['disabled'];
}
get scale() {
return this.pinchZoom.scale;
}
get isZoomedIn() {
return this.scale > 1;
}
get scaleLevel() {
return Math.round(this.scale / this._zoomControlScale);
}
get maxScale() {
return this.pinchZoom.maxScale;
}
get isZoomLimitReached() {
return this.scale >= this.maxScale;
}
get _zoomControlScale() {
return this.getPropertiesValue('zoomControlScale');
}
constructor(private elementRef: ElementRef) {
this.defaultComponentProperties = this.getDefaultComponentProperties();
this.applyPropertiesDefault(this.defaultComponentProperties, {});
}
ngOnInit() {
this.initPinchZoom();
/* Calls the method until the image size is available */
this.detectLimitZoom();
}
ngOnChanges(changes: SimpleChanges) {
let changedProperties = this.getProperties(changes);
changedProperties = this.renameProperties(changedProperties);
this.applyPropertiesDefault(this.defaultComponentProperties, changedProperties);
}
ngOnDestroy() {
this.destroy();
}
initPinchZoom() {
if (this.properties['disabled']) {
return;
get properties() {
return this._properties;
}
this.properties['element'] = this.elementRef.nativeElement.querySelector('.pinch-zoom-content');
this.pinchZoom = new IvyPinch(this.properties);
}
getProperties(changes: SimpleChanges) {
let properties: any = {};
for (var prop in changes) {
if (prop !== 'properties') {
properties[prop] = changes[prop].currentValue;
}
if (prop === 'properties') {
properties = changes[prop].currentValue;
}
}
return properties;
}
renameProperties(properties: any) {
for (var prop in properties) {
if (backwardCompatibilityProperties[prop]) {
properties[backwardCompatibilityProperties[prop]] = properties[prop];
delete properties[prop];
}
// transitionDuration
@Input('transition-duration') set transitionDurationBackwardCompatibility(value: number) {
if (value) {
this._transitionDuration = value;
}
}
return properties;
}
applyPropertiesDefault(defaultProperties: ComponentProperties, properties: ComponentProperties): void {
this.properties = Object.assign({}, defaultProperties, properties);
}
toggleZoom() {
this.pinchZoom.toggleZoom();
}
isControl() {
if (this.isDisabled) {
return false;
@Input('transitionDuration') set transitionDuration(value: number) {
if (value) {
this._transitionDuration = value;
}
}
if (this.properties['disableZoomControl'] === 'disable') {
return false;
get transitionDuration() {
return this._transitionDuration;
}
if (this.isTouchScreen && this.properties['disableZoomControl'] === 'auto') {
return false;
// doubleTap
@Input('double-tap') set doubleTapBackwardCompatibility(value: boolean) {
if (value) {
this._doubleTap = value;
}
}
return true;
}
detectLimitZoom() {
if (this.pinchZoom) {
this.pinchZoom.detectLimitZoom();
@Input('doubleTap') set doubleTap(value: boolean) {
if (value) {
this._doubleTap = value;
}
}
}
destroy() {
if (this.pinchZoom) this.pinchZoom.destroy();
}
getPropertiesValue(propertyName: PropertyName) {
if (this.properties && this.properties[propertyName]) {
return this.properties[propertyName];
} else {
return this.defaultComponentProperties[propertyName];
get doubleTap() {
return this._doubleTap;
}
}
getDefaultComponentProperties() {
return { ...defaultProperties, ..._defaultComponentProperties };
}
// doubleTapScale
@Input('double-tap-scale') set doubleTapScaleBackwardCompatibility(value: number) {
if (value) {
this._doubleTapScale = value;
}
}
@Input('doubleTapScale') set doubleTapScale(value: number) {
if (value) {
this._doubleTapScale = value;
}
}
get doubleTapScale() {
return this._doubleTapScale;
}
// autoZoomOut
@Input('auto-zoom-out') set autoZoomOutBackwardCompatibility(value: boolean) {
if (value) {
this._autoZoomOut = value;
}
}
@Input('autoZoomOut') set autoZoomOut(value: boolean) {
if (value) {
this._autoZoomOut = value;
}
}
get autoZoomOut() {
return this._autoZoomOut;
}
// limitZoom
@Input('limit-zoom') set limitZoomBackwardCompatibility(value: number | 'original image size') {
if (value) {
this._limitZoom = value;
}
}
@Input('limitZoom') set limitZoom(value: number | 'original image size') {
if (value) {
this._limitZoom = value;
}
}
get limitZoom() {
return this._limitZoom;
}
@Input() disabled!: boolean;
@Input() disablePan!: boolean;
@Input() overflow!: 'hidden' | 'visible';
@Input() zoomControlScale!: number;
@Input() disableZoomControl!: 'disable' | 'never' | 'auto';
@Input() backgroundColor!: string;
@Input() limitPan!: boolean;
@Input() minPanScale!: number;
@Input() minScale!: number;
@Input() listeners!: 'auto' | 'mouse and touch';
@Input() wheel!: boolean;
@Input() autoHeight!: boolean;
@Input() wheelZoomFactor!: number;
@Input() draggableImage!: boolean;
@HostBinding('style.overflow')
get hostOverflow() {
return this.properties['overflow'];
}
@HostBinding('style.background-color')
get hostBackgroundColor() {
return this.properties['backgroundColor'];
}
get isTouchScreen() {
var prefixes = ' -webkit- -moz- -o- -ms- '.split(' ');
var mq = function (query: any) {
return window.matchMedia(query).matches;
};
if ('ontouchstart' in window) {
return true;
}
// include the 'heartz' as a way to have a non matching MQ to help terminate the join
// https://git.io/vznFH
var query = ['(', prefixes.join('touch-enabled),('), 'heartz', ')'].join('');
return mq(query);
}
get isDragging() {
return this.pinchZoom ? this.pinchZoom.isDragging() : undefined;
}
get isDisabled() {
return this.properties['disabled'];
}
get scale() {
return this.pinchZoom.scale;
}
get isZoomedIn() {
return this.scale > 1;
}
get scaleLevel() {
return Math.round(this.scale / this._zoomControlScale);
}
get maxScale() {
return this.pinchZoom.maxScale;
}
get isZoomLimitReached() {
return this.scale >= this.maxScale;
}
get _zoomControlScale() {
return this.getPropertiesValue('zoomControlScale');
}
constructor(private elementRef: ElementRef) {
this.defaultComponentProperties = this.getDefaultComponentProperties();
this.applyPropertiesDefault(this.defaultComponentProperties, {});
}
ngOnInit() {
this.initPinchZoom();
/* Calls the method until the image size is available */
this.detectLimitZoom();
}
ngOnChanges(changes: SimpleChanges) {
let changedProperties = this.getProperties(changes);
changedProperties = this.renameProperties(changedProperties);
this.applyPropertiesDefault(this.defaultComponentProperties, changedProperties);
}
ngOnDestroy() {
this.destroy();
}
initPinchZoom() {
if (this.properties['disabled']) {
return;
}
this.properties['element'] = this.elementRef.nativeElement.querySelector('.pinch-zoom-content');
this.pinchZoom = new IvyPinch(this.properties);
}
getProperties(changes: SimpleChanges) {
let properties: any = {};
for (var prop in changes) {
if (prop !== 'properties') {
properties[prop] = changes[prop].currentValue;
}
if (prop === 'properties') {
properties = changes[prop].currentValue;
}
}
return properties;
}
renameProperties(properties: any) {
for (var prop in properties) {
if (backwardCompatibilityProperties[prop]) {
properties[backwardCompatibilityProperties[prop]] = properties[prop];
delete properties[prop];
}
}
return properties;
}
applyPropertiesDefault(defaultProperties: ComponentProperties, properties: ComponentProperties): void {
this.properties = Object.assign({}, defaultProperties, properties);
}
toggleZoom() {
this.pinchZoom.toggleZoom();
}
isControl() {
if (this.isDisabled) {
return false;
}
if (this.properties['disableZoomControl'] === 'disable') {
return false;
}
if (this.isTouchScreen && this.properties['disableZoomControl'] === 'auto') {
return false;
}
return true;
}
detectLimitZoom() {
if (this.pinchZoom) {
this.pinchZoom.detectLimitZoom();
}
}
destroy() {
if (this.pinchZoom) this.pinchZoom.destroy();
}
getPropertiesValue(propertyName: PropertyName) {
if (this.properties && this.properties[propertyName]) {
return this.properties[propertyName];
} else {
return this.defaultComponentProperties[propertyName];
}
}
getDefaultComponentProperties() {
return { ...defaultProperties, ..._defaultComponentProperties };
}
}

View file

@ -1,29 +1,32 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"paths": {
"ngx-pinch-zoom": [
"dist/ngx-pinch-zoom/ngx-pinch-zoom",
"dist/ngx-pinch-zoom"
]
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"paths": {
"ngx-pinch-zoom": [
"dist/ngx-pinch-zoom/ngx-pinch-zoom",
"dist/ngx-pinch-zoom"
]
},
"target": "es2015",
"module": "es2020",
"lib": [
"es2018",
"dom"
],
"types": [
"node"
]
},
"target": "es2015",
"module": "es2020",
"lib": [
"es2018",
"dom"
]
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false
}
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false
}
}