ng2-scroll-to

WebJar for ng2-scroll-to

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

ng2-scroll-to
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

ng2-scroll-to
WebJar for ng2-scroll-to
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/drusso85/ng2-scroll-to

Download ng2-scroll-to

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/ng2-scroll-to/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>ng2-scroll-to</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/ng2-scroll-to/
implementation 'org.webjars.npm:ng2-scroll-to:1.0.2'
// https://jarcasting.com/artifacts/org.webjars.npm/ng2-scroll-to/
implementation ("org.webjars.npm:ng2-scroll-to:1.0.2")
'org.webjars.npm:ng2-scroll-to:jar:1.0.2'
<dependency org="org.webjars.npm" name="ng2-scroll-to" rev="1.0.2">
  <artifact name="ng2-scroll-to" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='ng2-scroll-to', version='1.0.2')
)
libraryDependencies += "org.webjars.npm" % "ng2-scroll-to" % "1.0.2"
[org.webjars.npm/ng2-scroll-to "1.0.2"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : angular__core jar [2.1.2,3)

Project Modules

There are no modules declared in this project.

ng2-scroll-to

angular 2 library to animate scrolling to anchor links.

Features

  • jump to the top edge of an element referenced in the href attribute (href="#mytarget") or scrollTargetSelector attribute(scrollTargetSelector="#mytarget")
  • jump to the the to given coordinates (scrollYTarget="0")

Install

npm install ng2-scroll-to --save

Usage

Import ScrollToModule and add it to the imports array of your component.

// app.module.ts
import {ScrollToModule} from 'ng2-scroll-to';

@NgModule({
    imports: [
         ....,
        ScrollToModule.forRoot(),
        ]
})
export class AppModule {
}

In your template you may now add the scrollTo attribute to anchors elements.

// app.awesome.component.ts
@Component({
   ...
   template: `...
        <a scrollTo href="#main-section">Scroll to main section</a>
        <button scrollTo scrollTargetSelector="#test-section">Scroll to test section</a>
        <button scrollTo scrollableElementSelector="#container" scrollYTarget="0">Go top</a>
        <!-- Further content here -->
        <div id="container">
            <section id="main-section">Bla bla bla</section>
            <section id="test-section">Bla bla bla</section>
        <div>
   ...`,
})
export class AwesomeComponent {
}

Attributes

scrollTo required

scrollTargetSelector string Element target for scroll.

href string Element target for scroll.

scrollYTarget number Y axis target for scroll.

scrollableElementSelector string Scrollable element selector. Sometimes there are multiple scrollable elements in your page; through this attribute you may specify the element you want to scroll.

scrollOffSet number Top offset to compensate for negative top margins.

Versions

Version
1.0.2