├── .gitignore ├── .npmignore ├── LICENSE ├── README.md ├── compiled ├── index.ngfactory.ts ├── index.ngsummary.json └── src │ ├── scrollTo.ngfactory.ts │ └── scrollTo.ngsummary.json ├── index.metadata.json ├── index.ts ├── package.bk.json ├── package.json ├── src ├── scrollTo.metadata.json └── scrollTo.ts ├── tsconfig.json ├── tslint.json └── typings.json /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | # Node generated files 3 | node_modules 4 | npm-debug.log 5 | # OS generated files 6 | Thumbs.db 7 | .DS_Store 8 | # Ignored files 9 | *.js 10 | *.map 11 | *.d.ts -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # Node generated files 2 | node_modules 3 | npm-debug.log 4 | # OS generated files 5 | Thumbs.db 6 | .DS_Store 7 | # Ignored files 8 | *.ts 9 | !*.d.ts -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Davide Russo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ng2-scroll-to 2 | angular 2 library to animate scrolling to anchor links. 3 | 4 | ## Features 5 | - jump to the top edge of an element referenced in the href attribute (`href="#mytarget"`) or scrollTargetSelector attribute(`scrollTargetSelector="#mytarget"`) 6 | - jump to the the to given coordinates (`scrollYTarget="0"`) 7 | 8 | ## Install 9 | ```sh 10 | npm install ng2-scroll-to --save 11 | ``` 12 | ## Usage 13 | Import ScrollToModule and add it to the imports array of your component. 14 | 15 | 16 | 17 | ```typescript 18 | // app.module.ts 19 | import {ScrollToModule} from 'ng2-scroll-to'; 20 | 21 | @NgModule({ 22 | imports: [ 23 | ...., 24 | ScrollToModule.forRoot(), 25 | ] 26 | }) 27 | export class AppModule { 28 | } 29 | ``` 30 | 31 | 32 | In your template you may now add the `scrollTo` attribute to anchors elements. 33 | 34 | ```typescript 35 | // app.awesome.component.ts 36 | @Component({ 37 | ... 38 | template: `... 39 | Scroll to main section 40 |