{"_id":"@dsvishchov/nativescript-ngx-shadow","_rev":"4-d66e9a0febe75572834fc0723c6ba2d2","time":{"7.0.2":"2020-10-25T15:09:29.248Z","created":"2020-10-25T16:13:43.563Z","7.0.3":"2020-10-25T16:13:43.931Z","modified":"2022-04-05T06:00:31.349Z"},"name":"@dsvishchov/nativescript-ngx-shadow","dist-tags":{"latest":"7.0.3"},"versions":{"7.0.3":{"name":"@dsvishchov/nativescript-ngx-shadow","version":"7.0.3","description":"Nativescript Angular Shadow","main":"ngx-shadow","typings":"index.d.ts","nativescript":{"platforms":{"android":"6.5.0","ios":"6.5.0"}},"repository":{"type":"git","url":"git+https://github.com/dsvishchov/nativescript-ngx-shadow.git"},"scripts":{"tsc":"npm i && ts-patch install && tsc","build":"npm i && ts-patch install && npm run ngcc && npm run ngc","build.old":"npm i && ts-patch install && npm run ngcc && npm run ngc && npm run build.native","build.native":"","tslint":"cd .. && tslint \"**/*.ts\" --config tslint.json --exclude \"**/node_modules/**\" --exclude \"**/typings/**\"","ci.tslint":"npm i && ts-patch install && tslint '**/*.ts' --config '../tslint.json' --exclude '**/node_modules/**' --exclude '**/platforms/**' --exclude '**/typings/**'","prepack":"npm run build.native","demo.ios":"npm i && ts-patch install && cd ../demo && ns run ios","demo.android":"npm i && ts-patch install && cd ../demo && ns run android","demo.reset":"cd ../demo && npx rimraf -- hooks node_modules platforms package-lock.json","demo-angular.ios":"npm i && ts-patch install && cd ../demo-angular && ns run ios","demo-angular.android":"npm i && ts-patch install && cd ../demo-angular && ns run android","demo-angular.reset":"cd ../demo-angular && npx rimraf -- hooks node_modules platforms package-lock.json","plugin.prepare":"npm run build && cd ../demo && ns plugin remove nativescript-ngx-shadow && ns plugin add ../src && cd ../demo-angular && ns plugin remove nativescript-ngx-shadow && ns plugin add ../src","clean":"npm run demo.reset && npm run demo-angular.reset && npx rimraf -- node_modules package-lock.json && npm i","ngcc":"node --max-old-space-size=8192 ./node_modules/.bin/ngcc -p es2015","ngc":"node --max-old-space-size=8192 ./node_modules/.bin/ngc"},"keywords":["NativeScript","JavaScript","Android","iOS"],"author":{"name":"Dmitry Svishchov","email":"dsvishchov@gmail.com"},"bugs":{"url":"https://github.com/dsvishchov/nativescript-ngx-shadow/issues"},"license":"Apache-2.0","homepage":"https://github.com/dsvishchov/nativescript-ngx-shadow","devDependencies":{"@angular/common":"^10.1.0","@angular/compiler":"^10.1.0","@angular/compiler-cli":"^10.1.0","@angular/core":"^10.1.0","@nativescript/angular":"^10.1.5","@nativescript/core":"~7.0.3","@nativescript/types":"~7.0.3","@nativescript/webpack":"~3.0.4","prompt":"^1.0.0","rimraf":"^2.6.3","rxjs":"~6.5.5","semver":"^5.6.0","ts-patch":"^1.3.0","tslint":"^6.1.2","typescript":"3.9.7"},"dependencies":{"ts-node":"^9.0.0","typescript":"3.9.7"},"bootstrapper":"nativescript-plugin-seed","_resolved":"","_integrity":"","_from":"file:dsvishchov-nativescript-ngx-shadow-7.0.3.tgz","_id":"@dsvishchov/nativescript-ngx-shadow@7.0.3","_nodeVersion":"14.8.0","_npmVersion":"6.14.7","dist":{"integrity":"sha512-uM/YT82dPNv0o4xU73AyVnA/w/Lb8nuMWEJMApSVNZEaysMvWY6WAEvbPz9o5MK+EPGSjKsckWokhin1FqGuWQ==","shasum":"0bc18307394c03ef452828739c9af6452e47e10f","tarball":"https://registry.npmjs.org/@dsvishchov/nativescript-ngx-shadow/-/nativescript-ngx-shadow-7.0.3.tgz","fileCount":22,"unpackedSize":61822,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJflaQ4CRA9TVsSAnZWagAAP8YQAIAbCiGmdfBZy+BTyq3Q\nhX4a8r8dGSvw+xJVbliFCemGUxqW/h0hkQdJaKHup1G6yngnqP1ePR6arO0x\nBSuljQK9seY0d++r+qFWUValjEvM8gBdaYe4jFIgpe/MaFCxluWxYL2l5ZQ1\nzRROH2Fm45/JwBIGesxci2gev/gQCUV4BpOMyXaZg8KItq0RudB+Y8oSyyvS\nOBIW8thS6EqnISLItiBnpNlsUXuBpZ4FkeHkwNECNzJZKoInz0HzZxKmIpEN\nXAHiO1BHsbKJx7mUFyAAuqOKoJapJ/XVhGcK3fI0o1XQPtJZ3nlzq8XzmLF0\nRriL+eQhyiYN7r8ksWb1pxVowxnEG0rS6aJTNgv2GdnPwGVmTiA6wLANV5A5\noYQ6hBI5JxIHhN2H0NsofD2z+9QPErRpZn9R2MYH0WsTTY61jwG8dakjoMaM\nPBtATTg0o0MgQy4jL2UWHJ3u5ubKHkGGdZsXm06Ao71G4i6eR6IvkqGxygtc\nywKsLOCTQyS/zawDBicZhEXTxpI6zSqZR4AN/BEmXLpFeOXtfQEWMxoHQn0x\nmLn37IYAh/FtdKKKAaoUAVwkEbqR9R5JGxHKcsOpnURjVmcMPwRKJj1cRjth\nvgO0QC9VIR2FPraa47fYRdW2JkiXHJ2ekzN6PPZY8tpWcZ+ylsaEXaQ5i7RJ\no/TG\r\n=aAhB\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDy0tSlJOS7oCVJiv6tnK+lA6xhyWj052H5ovVPk1f25wIhAM5w0CRBStiCBvfIGXL2uPkXVeG+HhFkhKOhFzbdc7bE"}]},"maintainers":[{"name":"dsvishchov","email":"dsvishchov@gmail.com"}],"_npmUser":{"name":"dsvishchov","email":"dsvishchov@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nativescript-ngx-shadow_7.0.3_1603642423596_0.9383755744083011"},"_hasShrinkwrap":false}},"maintainers":[{"name":"dsvishchov","email":"dsvishchov@gmail.com"}],"description":"Nativescript Angular Shadow","homepage":"https://github.com/dsvishchov/nativescript-ngx-shadow","keywords":["NativeScript","JavaScript","Android","iOS"],"repository":{"type":"git","url":"git+https://github.com/dsvishchov/nativescript-ngx-shadow.git"},"author":{"name":"Dmitry Svishchov","email":"dsvishchov@gmail.com"},"bugs":{"url":"https://github.com/dsvishchov/nativescript-ngx-shadow/issues"},"license":"Apache-2.0","readme":"# NativeScript Angular Shadow Directive Plugin ![apple](https://cdn3.iconfinder.com/data/icons/picons-social/57/16-apple-32.png) ![android](https://cdn4.iconfinder.com/data/icons/logos-3/228/android-32.png)\n\n[![NPM version][npm-image]][npm-url]\n[![Downloads][downloads-image]][npm-url]\n[![Twitter Follow][twitter-image]][twitter-url]\n\n[npm-image]: http://img.shields.io/npm/v/nativescript-ngx-shadow.svg\n[npm-url]: https://npmjs.org/package/nativescript-ngx-shadow\n[downloads-image]: http://img.shields.io/npm/dt/nativescript-ngx-shadow.svg\n[twitter-image]: https://img.shields.io/twitter/follow/_joshsommer.svg?style=social&label=Josh%20Sommer\n[twitter-url]: https://twitter.com/_joshsommer\n\nThis repo is a fork of @Especializa's NativeScript Shadow Directive.\nhttps://github.com/Especializa/nativescript-ng-shadow\n\n## Installation\n\nFrom the command prompt go to your app's root folder and execute:\n\n```\ntns plugin add nativescript-ngx-shadow\n```\n\n## Demo\n\n[![N|Solid](demo/app/tools/assets/screenshot.png)](https://www.udemy.com/angular-native)\n\n### How to use it\n\nThis is an Angular directive to make your life easier when it comes to native shadows.\n\nShadows are a very important part of [Material design specification](https://material.io/).\nIt brings up the [concept of elevation](https://material.io/guidelines/material-design/elevation-shadows.html), which implies in the natural human way of perceiving objects raising up from the surface.\n\nWith this directive, you won't have to worry about all the aspects regarding shadowing on Android and on iOS.\nOn the other hand, if you care about any details, just provide extra attributes and they will superseed the default ones.\n\nHowever, running this on Android you will require the SDK to be greater or equal than 21 (Android 5.0 Lollipop or later), otherwise shadows will simply not be shown. There should be no problem running this on any version of iOS.\n\n#### Import the NgShadowModule\n\n```typescript\n// ...\nimport { NgShadowModule } from \"nativescript-ngx-shadow\";\n\n@NgModule({\n  imports: [\n    NgShadowModule\n    // ...\n  ]\n  // ...\n})\nexport class MyModule {}\n```\n\n#### Just use in your templates\n\nSimple attribute `shadow`:\n\n```xml\n<Label shadow=\"2\"></Label>\n```\n\nOf course you can property bind it:\n\n```xml\n<Label [shadow]=\"myCustomShadow\"></Label>\n```\n\nTo provide other details, combine the `shadow` directive with other attributes:\n\n```xml\n<Label shadow [elevation]=\"myElevation\" cornerRadius=\"5\"></Label>\n```\n\nThere are a couple of platform specific attributes you might want to use to customize your view. Bear in mind some of them clash with CSS styles applied to the same views. When it happens, the default behaviour on Android is the original HTML/CSS styles are lost in favor of the ones provided by this directive. On iOS, on the other hand, HTML/CSS pre-existent styles are regarded, consequently the shadow might not be applied.\n\nThe tip is avoid applying things like **background color** and **border radius** to the same view you intend to apply this directive (Note: this is now supported). You are always able to nest views and get what you want. If not, please [leave a message](https://github.com/Especializa/nativescript-ngx-shadow/issues) so we can try to help.\n\n### List of attributes\n\nThe table below list and describes all possible attributes as well as show which platform supports each one of them:\n\n| Attribute     | Type                                                                                                                                                                                                                                                         | Platform | Description                                                                                                                                                                                                                                                                                                                                                                                                               |\n| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| shadow        | string \\| number \\| [AndroidData](https://github.com/TheOriginaljosh/nativescript-ngx-shadow/blob/master/src/common/android-data.model.ts) \\| [IOSData](https://github.com/TheOriginaljosh/nativescript-ngx-shadow/blob/master/src/common/ios-data.model.ts) | both     | Directive attribute. Providing `null` or empty string with no `elevation` attribute, will switch off the shadow                                                                                                                                                                                                                                                                                                           |\n| elevation     | number \\| string                                                                                                                                                                                                                                             | both     | Determines the elevation of the view from the surface. It does all shadow related calculations. You might want to have a look at [this enum](https://github.com/TheOriginalJosh/nativescript-ngx-shadow/blob/master/lib/src/nativescript-ngx-shadow/common/elevation.enum.ts) of standard material design elevations. <br>PS: Since version 2.0, it's calculated in DIPs (or DPs, _density independent pixels_) on Android, or PTs (_points_) on iOS. |\n| pressedElevation     | number \\| string                                                                                                                                                                                                                                      | Android     | Determines the view's elevation when on pressed state.    |\n| shape         | string => `'RECTANGLE'` \\| `'OVAL'` \\| `'RING'` \\| `'LINE'` <br/>default: `'RECTANGLE'`                                                                                                                                                                      | Android  | Determines the shape of the view and overrides its format styles.                                                                                                                                                                                                                                                                                                                                                         |\n| bgcolor       | string => color #RGB                                                                                                                                                                                                                                         | Android  | Determines view's background color and overrides its previous background. If not set, the previous background is used. **NOTE:** setting the background to transparent is known to cause issues on Android (the shadow may overlap the background)                                                                                                                                                                                                                                                                             |\n| cornerRadius  | number                                                                                                                                                                                                                                                       | Android  | Determines view's corner radius _(CSS border-radius)_ and overrides its previous style. If this is not set, the view's CSS border-radius are used. <br>PS: Since version 2.0, it's calculated in DIPs (or DPs, _density independent pixels_).                                                                                                                                              |\n| translationZ  | number                                                                                                                                                                                                                                                       | Android  | Determines an extra distance (in DIP) to the surface.                                                                                                                                                                                                                                                                                                                                                                     |\n| pressedTranslationZ  | number                                                                                                                                                                                                                                                | Android  | Determines an extra distance (in DIP) to the surface when the view is in the pressed state.                                                                                                                                                                                                                                                                                                                                    |\n| forcePressAnimation  | boolean => default: false                                                                                                                                                                                                                             | Android  | By default, if a view has a StateAnimator, it is overwritten by an animator that raises the View on press. Setting this to true will always define this new animator, essentially making any clickable View work as a button.                                                                                                                                                                                                    |\n| maskToBounds  | boolean => default: false                                                                                                                                                                                                                                    | iOS      | Determines whether the shadow will be limited to the view margins.                                                                                                                                                                                                                                                                                                                                                        |\n| shadowColor   | string => color #RGB                                                                                                                                                                                                                                         | iOS      | Determines shadow color. Shadow won't be applied if the view already has background.                                                                                                                                                                                                                                                                                                                                      |\n| shadowOffset  | number                                                                                                                                                                                                                                                       | iOS      | Determines the distance in points (only on Y axis) of the shadow. Negative value shows the shadow above the view.                                                                                                                                                                                                                                                                                                         |\n| shadowOpacity | number                                                                                                                                                                                                                                                       | iOS      | From 0 to 1. Determines the opacity level of the shadow.                                                                                                                                                                                                                                                                                                                                                                  |\n| shadowRadius  | number                                                                                                                                                                                                                                                       | iOS      | Determines the blurring effect in points of the shadow. The higher the more blurred.                                                                                                                                                                                                                                                                                                                                      |\n| useShadowPath  | boolean => default: true                                                                                                                                                                                                                                    | iOS      | Determines whether to use shadowPath to render the shadow. Setting this to false negatively impacts performance.                                                                                                                                                                                                                                                                                                   |\n| rasterize  | boolean => default: false                                                                                                                                                                                                                                       | iOS      | Determines whether the view should be rasterized. Activating this will increase memory usage, as rasterized views are stored in memory, but will massively improve performance.                                                                                                                                                                                                                                   |\n\n### `AndroidData` and `IOSData`\n\nAs you might have noticed the main `shadow` attribute accepts object as argument. You'll be able to assign it in a property bind and it will override any possible separate attribute you might have defined:\n\n#### Component\n\n```typescript\nimport { AndroidData, ShapeEnum } from \"nativescript-ngx-shadow\";\n// ...\nexport class MyComponent {\n  fabShadow: AndroidData = {\n    elevation: 6,\n    bgcolor: \"#ff1744\",\n    shape: ShapeEnum.OVAL\n  };\n  // ...\n}\n```\n\nIn the template you can do:\n\n```xml\n<Label [shadow]=\"fabShadow\" width=\"56\" height=\"56\"></Label>\n```\n\n## Pre-defined elevations\n\nIf you want to be consistent with the Material Design specification but you're sick trying to memorize which elevation your view should have. We put together a list of pre-defined elevations:\n\n- SWITCH: 1\n- CARD_RESTING: 2\n- RAISED_BUTTON_RESTING: 2\n- SEARCH_BAR_RESTING: 2\n- REFRESH_INDICADOR: 3\n- SEARCH_BAR_SCROLLED: 3\n- APPBAR: 4\n- FAB_RESTING: 6\n- SNACKBAR: 6\n- BOTTOM_NAVIGATION_BAR: 8\n- MENU: 8\n- CARD_PICKED_UP: 8,\n- RAISED_BUTTON_PRESSED: 8\n- SUBMENU_LEVEL1: 9\n- SUBMENU_LEVEL2: 10\n- SUBMENU_LEVEL3: 11\n- SUBMENU_LEVEL4: 12\n- SUBMENU_LEVEL5: 13\n- FAB_PRESSED: 12\n- NAV_DRAWER: 16\n- RIGHT_DRAWER: 16\n- MODAL_BOTTOM_SHEET: 16\n- DIALOG: 24\n- PICKER: 24\n\nIf you don't even want to check it out every time you have to shadow a view, just import the `Elevation` enum and enjoy :)\n\n#### Component\n\n```typescript\nimport { Elevation } from \"nativescript-ngx-shadow\";\nclass MyComponent {\n  // ...\n  ngOnInit(): init {\n    this.mySnackBar.elevation = Elevation.SNACKBAR;\n  }\n  // ...\n}\n```\n\n## Notes about version 2+\n\nHere are the list of improvements on version 2.0:\n\n1.  BugFix: Integer directive not rendering on iOS.\n1.  Density independent pixels: Now you no longer have to worry about providing\n    the correct values for pixel related attributes based on the device's\n    screen density.\n    Since iPhone 6S, each point correspond to 9 device pixels\n    (3 horizontally x 3 vertically - that's the reason behind the @3x images -\n    [view more here](https://medium.com/@pnowelldesign/pixel-density-demystified-a4db63ba2922)).\n    The same happens to Android where the benchmark (mdpi) is considered ~160 pixels\n    (or dots) per inch (dpi) and the majority of the modern devices having way\n    denser screens, reaching ~640dpi or more.\n    [Find out more here](https://developer.android.com/guide/practices/screens_support.html).\n1.  New Android specific attribute called translationZ. The elevation attribute\n    is the baseline of the virtual Z axis (3D axis), but according to the [official\n    documentation](https://developer.android.com/training/material/shadows-clipping.html)\n    it's not the only part. Then, `translationZ` will add extra distance to the surface\n    and it's mainly used for animations.\n1.  **2.1.X** Override Android default StateListAnimator as explained below:\n\n### Override Android default StateListAnimator\n\nAndroid buttons are split into three categories:\nfloating, raised and flat. Different from labels and other ui elements,\neach button category has its own state animator.\nSo, when buttons are tapped, Android does affect their elevation\n(and z translation) in a way that Angular is not notified. At the end of tap animation, buttons get back to\nresting defaults (i.e. raised button's `elevation` at 2dp and `translationZ` at 0) overriding\nthe shadow stablished by this plugin.\n\nSince version 2.1.0, this plugin replaces the default `StateListAnimator` with one\nthat gets back to the values you provide for `elevation` and `translationZ`.\n\nFeel free to fill an issue if you want the flexibility of defining your own\n`StateListAnimator`. The motivation so far was simply put this plugin to work with\nbuttons without changing the original state once they are clicked.\n\nIt's also possible to set this `StateListAnimator` to any View, making it behave like a button.\n\n## Plugin Development Work Flow:\n\n- Clone repository to your machine.\n- Run `npm install` to prepare the project\n- Run and deploy to your device or emulator with `npm run android` or `npm run ios`\n- Build a ngPackagr version with `npm run build`\n\n## Changelog\n\n- 6.0.0 Fork: Now packaged with ngPackagr for Angular 6 compatabilty\n- 2.1.0 Decouple shadow logic / Override default StateListAnimator\n- 2.0.1 Fix error on old Android devices (< Lollipop)\n- 2.0.0 Density Independent Pixels / TranslationZ\n- 1.1.3 Minor issues\n- 1.1.2 Fix CI build\n- 1.1.0 Support for iOS custom attributes\n- 1.0.0 Initial implementation\n\n## License\n\nApache License Version 2.0, January 2004\n","readmeFilename":"README.md"}