1.0.1 • Published 6 months ago

sa-totop v1.0.1

Weekly downloads
-
License
-
Repository
-
Last release
6 months ago

Angular To Top Library

The Angular To Top library provides a customizable "Scroll to Top" button for your Angular applications. It offers a variety of options for configuring the button's appearance, behavior, and functionality.

Installation

To install the library, use the following command:

npm install sa-totop

Usage

1. Import the directive

To use the sa-totop component in your Angular application, first import it and include it in your template:

import { TotopComponent } from "sa-totop";
<sa-totop></sa-totop>

Custom Button Content

If you wish to use custom content for the button, set the customeBtn input to true and pass your custom content inside the sa-totop component:

<sa-totop [width]="40" [customeBtn]="true">
  <span>up</span>
</sa-totop>

Inputs

InputTypeDefaultDescription
bottomnumber20position of the button in pixels.
endnumber20position of the button in pixels (inset-inline-end).
widthnumber40Size of the button in pixels.
colorstring'#0891b2'Color of the button.
scrollBehaviorScrollBehavior'smooth'Type of scroll animation. Options: 'instant','smooth', 'auto'.
backgroundstring'transparent'Background color of the button.
durationnumber0.3Speed of the animation in seconds.
visibilityHeightnumber450Height in pixels before the button becomes visible.
visibilityHiddenbooleantrueIf false, the button will hide when the scroll height reaches the value.
customeBtnbooleanfalseAllows the use of custom button content.

Outputs

OutputDescription
scrollCompleteEmits an event when the scroll to the top is complete.
toTopClickedEmits an event when the button is clicked to scroll to the top.
<sa-totop [width]="40" [bottom]="50" [end]="30" [color]="'#0891b2'" [scrollBehavior]="'smooth'" [background]="'transparent'" [duration]="0.3" [visibilityHeight]="450" [visibilityHidden]="true" [customeBtn]="false" (scrollComplete)="onScrollComplete()" (toTopClicked)="onToTopClicked()"> </sa-totop>

License

MIT License