Repository: vdolek/angular-resize-event Branch: master Commit: d577ba9f01ba Files: 32 Total size: 24.3 KB Directory structure: gitextract_9dohus3n/ ├── .editorconfig ├── .github/ │ └── workflows/ │ ├── ci.yml │ └── npm-publish.yml ├── .gitignore ├── LICENSE ├── README.md ├── angular.json ├── package.json ├── playground/ │ ├── .browserslistrc │ ├── .editorconfig │ ├── angular.json │ ├── package.json │ ├── src/ │ │ ├── app/ │ │ │ ├── app.component.html │ │ │ ├── app.component.scss │ │ │ ├── app.component.ts │ │ │ └── app.module.ts │ │ ├── index.html │ │ ├── main.ts │ │ ├── polyfills.ts │ │ └── styles.scss │ ├── tsconfig.app.json │ └── tsconfig.json ├── projects/ │ └── angular-resize-event/ │ ├── README.md │ ├── ng-package.json │ ├── package.json │ ├── src/ │ │ ├── lib/ │ │ │ ├── angular-resize-event.module.ts │ │ │ ├── resized.directive.ts │ │ │ └── resized.event.ts │ │ └── public-api.ts │ ├── tsconfig.lib.json │ └── tsconfig.lib.prod.json └── tsconfig.json ================================================ FILE CONTENTS ================================================ ================================================ FILE: .editorconfig ================================================ # Editor configuration, see https://editorconfig.org root = true [*] charset = utf-8 indent_style = space indent_size = 2 insert_final_newline = true trim_trailing_whitespace = true [*.ts] quote_type = single [*.md] max_line_length = off trim_trailing_whitespace = false ================================================ FILE: .github/workflows/ci.yml ================================================ # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions name: CI on: push: pull_request: jobs: build: runs-on: ubuntu-latest strategy: matrix: node-version: [14.x, 16.x] steps: - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - run: npm ci # - run: npm run lint - run: npm run build # - run: npm test ================================================ FILE: .github/workflows/npm-publish.yml ================================================ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created # For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages name: Publish Package on: release: types: [created] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: node-version: 16 - run: npm ci - run: npm run build publish-npm: needs: build runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: node-version: 16 registry-url: https://registry.npmjs.org/ - run: npm ci - run: npm run build - run: npm publish working-directory: dist/angular-resize-event env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} # publish-gpr: # needs: build # runs-on: ubuntu-latest # steps: # - uses: actions/checkout@v2 # - uses: actions/setup-node@v1 # with: # node-version: 16 # registry-url: https://npm.pkg.github.com/ # - run: npm ci # - run: npm publish # env: # NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} ================================================ FILE: .gitignore ================================================ # See http://help.github.com/ignore-files/ for more about ignoring files. # Compiled output /dist /tmp /out-tsc /bazel-out # Node /node_modules npm-debug.log yarn-error.log # IDEs and editors .idea/ .project .classpath .c9/ *.launch .settings/ *.sublime-workspace # Visual Studio Code .vscode/* !.vscode/settings.json !.vscode/tasks.json !.vscode/launch.json !.vscode/extensions.json .history/* # Miscellaneous /.angular/cache .sass-cache/ /connect.lock /coverage /libpeerconnection.log testem.log /typings # System Files .DS_Store Thumbs.db ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2020 Martin Volek Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # Angular Resize Event [](https://github.com/vdolek/angular-resize-event) [](https://www.npmjs.com/package/angular-resize-event) [](https://github.com/vdolek/angular-resize-event/actions?query=workflow%3ACI) [](https://www.npmjs.com/package/angular-resize-event) [](https://snyk.io/test/github/vdolek/angular-resize-event) Angular 14 directive for detecting changes of an element size. It is as simple as: ```html
``` It internally uses browser native [`ResizeObserver`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver). Therefore it is not supported in IE. For Angular 11 you can use version 2.1.0 which internally uses uses `ResizeSensor` from [CSS Element Queries](https://github.com/marcj/css-element-queries) that is supported in IE. ## Playground [StackBlitz playground](https://stackblitz.com/edit/angular-resize-event-playground?file=src/app/app.component.html) ## Using the library Import the library in any Angular application by running: ```bash $ npm install angular-resize-event ``` and then from your Angular `AppModule`: ```typescript import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { AppComponent } from './app.component'; // Import the library module import { AngularResizeEventModule } from 'angular-resize-event'; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, // Specify AngularResizeEventModule library as an import AngularResizeEventModule ], providers: [], bootstrap: [ AppComponent ] }) export class AppModule { } ``` Once your library is imported, you can use its `resized` directive in your Angular application: ```html ``` ```typescript import { Component } from '@angular/core'; // Import the resized event model import { ResizedEvent } from 'angular-resize-event'; @Component({...}) class MyComponent { width: number; height: number; onResized(event: ResizedEvent) { this.width = event.newRect.width; this.height = event.newRect.height; } } ``` ## License MIT © [Martin Volek](mailto:martin@vdolek.cz) ================================================ FILE: angular.json ================================================ { "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "version": 1, "newProjectRoot": "projects", "projects": { "angular-resize-event": { "projectType": "library", "root": "projects/angular-resize-event", "sourceRoot": "projects/angular-resize-event/src", "prefix": "lib", "architect": { "build": { "builder": "@angular-devkit/build-angular:ng-packagr", "options": { "project": "projects/angular-resize-event/ng-package.json" }, "configurations": { "production": { "tsConfig": "projects/angular-resize-event/tsconfig.lib.prod.json" }, "development": { "tsConfig": "projects/angular-resize-event/tsconfig.lib.json" } }, "defaultConfiguration": "production" }, "test": { "builder": "@angular-devkit/build-angular:karma", "options": { "main": "projects/angular-resize-event/src/test.ts", "tsConfig": "projects/angular-resize-event/tsconfig.spec.json", "karmaConfig": "projects/angular-resize-event/karma.conf.js" } } } } }, "cli": { "analytics": false } } ================================================ FILE: package.json ================================================ { "name": "angular-resize-event", "version": "3.2.0", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "watch": "ng build --watch --configuration development", "test": "ng test", "postbuild": "cp README.md dist/angular-resize-event/README.md" }, "private": true, "dependencies": { "@angular/animations": "^14.0.2", "@angular/common": "^14.0.2", "@angular/compiler": "^14.0.2", "@angular/core": "^14.0.2", "@angular/forms": "^14.0.2", "@angular/platform-browser": "^14.0.2", "@angular/platform-browser-dynamic": "^14.0.2", "@angular/router": "^14.0.2", "rxjs": "~7.5.0", "tslib": "^2.3.0", "zone.js": "~0.11.4" }, "devDependencies": { "@angular-devkit/build-angular": "^14.0.2", "@angular/cli": "^14.0.2", "@angular/compiler-cli": "^14.0.2", "@types/jasmine": "~4.0.0", "@types/node": "^12.11.1", "jasmine-core": "~4.1.0", "karma": "~6.3.0", "karma-chrome-launcher": "~3.1.0", "karma-coverage": "~2.2.0", "karma-jasmine": "~5.0.0", "karma-jasmine-html-reporter": "~1.7.0", "ng-packagr": "^14.0.2", "typescript": "~4.7.3" } } ================================================ FILE: playground/.browserslistrc ================================================ # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. # For additional information regarding the format and rule options, please see: # https://github.com/browserslist/browserslist#queries # For the full list of supported browsers by the Angular framework, please see: # https://angular.io/guide/browser-support # You can see what browsers were selected by your queries by running: # npx browserslist last 1 Chrome version last 1 Firefox version last 2 Edge major versions last 2 Safari major versions last 2 iOS major versions Firefox ESR not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line. ================================================ FILE: playground/.editorconfig ================================================ # Editor configuration, see https://editorconfig.org root = true [*] charset = utf-8 indent_style = space indent_size = 2 insert_final_newline = true trim_trailing_whitespace = true [*.ts] quote_type = single [*.md] max_line_length = off trim_trailing_whitespace = false ================================================ FILE: playground/angular.json ================================================ { "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "version": 1, "newProjectRoot": "projects", "projects": { "playground": { "projectType": "application", "schematics": { "@schematics/angular:component": { "style": "scss" }, "@schematics/angular:application": { "strict": true } }, "root": "", "sourceRoot": "src", "prefix": "app", "architect": { "build": { "builder": "@angular-devkit/build-angular:browser", "options": { "outputPath": "dist/playground", "index": "src/index.html", "main": "src/main.ts", "polyfills": "src/polyfills.ts", "tsConfig": "tsconfig.app.json", "inlineStyleLanguage": "scss", "preserveSymlinks": true, "assets": [ "src/favicon.ico", "src/assets" ], "styles": [ "src/styles.scss" ], "scripts": [] }, "configurations": { "production": { "budgets": [ { "type": "initial", "maximumWarning": "500kb", "maximumError": "1mb" }, { "type": "anyComponentStyle", "maximumWarning": "2kb", "maximumError": "4kb" } ], "outputHashing": "all" }, "development": { "buildOptimizer": false, "optimization": false, "vendorChunk": true, "extractLicenses": false, "sourceMap": true, "namedChunks": true } }, "defaultConfiguration": "production" }, "serve": { "builder": "@angular-devkit/build-angular:dev-server", "configurations": { "production": { "browserTarget": "playground:build:production" }, "development": { "browserTarget": "playground:build:development" } }, "defaultConfiguration": "development" }, "extract-i18n": { "builder": "@angular-devkit/build-angular:extract-i18n", "options": { "browserTarget": "playground:build" } }, "test": { "builder": "@angular-devkit/build-angular:karma", "options": { "main": "src/test.ts", "polyfills": "src/polyfills.ts", "tsConfig": "tsconfig.spec.json", "karmaConfig": "karma.conf.js", "inlineStyleLanguage": "scss", "assets": [ "src/favicon.ico", "src/assets" ], "styles": [ "src/styles.scss" ], "scripts": [] } } } } }, "defaultProject": "playground" } ================================================ FILE: playground/package.json ================================================ { "name": "playground", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "watch": "ng build --watch --configuration development", "test": "ng test" }, "private": true, "dependencies": { "@angular/animations": "~13.1.0", "@angular/common": "~13.1.0", "@angular/compiler": "~13.1.0", "@angular/core": "~13.1.0", "@angular/forms": "~13.1.0", "@angular/platform-browser": "~13.1.0", "@angular/platform-browser-dynamic": "~13.1.0", "@angular/router": "~13.1.0", "rxjs": "~7.4.0", "angular-resize-event": "file:../dist/angular-resize-event", "tslib": "^2.3.0", "zone.js": "~0.11.4" }, "devDependencies": { "@angular-devkit/build-angular": "~13.1.1", "@angular/cli": "~13.1.1", "@angular/compiler-cli": "~13.1.0", "@types/jasmine": "~3.8.0", "@types/node": "^12.11.1", "jasmine-core": "~3.8.0", "karma": "~6.3.0", "karma-chrome-launcher": "~3.1.0", "karma-coverage": "~2.0.3", "karma-jasmine": "~4.0.0", "karma-jasmine-html-reporter": "~1.7.0", "typescript": "~4.5.2" } } ================================================ FILE: playground/src/app/app.component.html ================================================