0.6.1 • Published 1 year ago

@internetguru/scrolltopable v0.6.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

GitHub Workflow Status GitHub npm GitHub file size in bytes

Scrolltopable

Scrolltopable is a JavaScript module that provides ultimate scroll-to-top functionality. No dependencies and frameworks, pure JavaScript!

See our demo.

Simple Usage

<head>
  <!-- include basic css -->
  <link rel="stylesheet" type="text/css" href="https://unpkg.com/@internetguru/scrolltopable@latest/basic.css"/>
  <!-- include scrolltopable -->
  <script type="module" src="https://unpkg.com/@internetguru/scrolltopable@latest/index.min.js"></script>
  <!-- initialization with modifying default options -->
  <script type="module">
    import { Scrolltopable } from './index.min.js'
    Scrolltopable.init({
      text: 'Top',
      hideTop: 0,
    })
  </script>
</head>

Note: you can install package locally by running npm i @internetguru/scrolltopable --save.

Advanced Example

Launch a rocket after clicking a button! See it in production.

<head>
  <!-- include basic css -->
  <link rel="stylesheet" type="text/css" href="https://unpkg.com/@internetguru/scrolltopable@latest/basic.css"/>
  <!-- include fontawesome -->
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/js/all.min.js"></script>
  <!-- include scrolltopable -->
  <script type="module" src="index.js"></script>
  <!-- initialization with modifying default options -->
  <script type="module">
    import { Scrolltopable } from './index.js'
    Scrolltopable.init({
      text: "<span class='fa fa-fw fa-space-shuttle fa-rotate-270'></span>",
      activeTimeout: 1500
    })
  </script>
  <!-- launch animation and rocket icon styles -->
  <style type="text/css">
    html {
      scroll-behavior: smooth;
    }
    #js-scrolltopable {
      background: none;
    }
    #js-scrolltopable svg {
      position: relative;
      left: 0;
      top: -0.25em;
      font-size: 0.65em;
      color: black;
    }
    #js-scrolltopable.js-scrolltopable--active {
      animation-name: launch;
      animation-duration: 1s;
      animation-timing-function: ease-in;
      animation-fill-mode: forwards;
      opacity: 1;
    }
    @keyframes launch {
      90% {bottom: 100vh; opacity: 1;}
      100% {bottom: 100vh; opacity: 0;}
    }
  </style>
</head>

Options

Configuration nameDefault valueDescription
contentButton content (raw HTML)
titleTopButton title
idjs-scrolltopableButton id and class name
visibleClassjs-scrolltopable--visibleClass for visible button
activeClassjs-scrolltopable--activeClass for active button
extraClassnoprintList of extra classes separated by space
hideBeforeTop500No-show zone from the top (px)
showBeforeBottom500No-hide zone from the button (px)
showAfterUp200Show the button after scrolling up (px)
hideAfterDown200Hide the button after scrolling down (px)
activeTime0Keep activeClass after clicking the button (ms)
scrollActionDelay200Wait before evaluating scrolling (ms)

Maintainers

  • Paulo Petrzela paulo@internetguru.io
  • George Pavelka george@internetguru.io

Contributing

Pull requests are welcome, don't hesitate to contribute.

Donation

If you find this program useful, please send a donation to its developers to support their work. If you use this program at your workplace, please suggest that the company make a donation. We appreciate contributions of any size. Donations enable us to spend more time working on this package, and help cover our infrastructure expenses.

If you’d like to make a donation of any value, please send it to the following PayPal address:

PayPal Donation

Since we aren’t a tax-exempt organization, we can’t offer you a tax deduction. But for all donations over 50 USD, we’d be happy to recognize your contribution on this README file for the next release.

We are also happy to consider making particular improvements or changes, or giving specific technical assistance, in return for a substantial donation over 100 USD. If you would like to discuss this possibility, write us at info@internetguru.io.

Another possibility is to pay a software maintenance fee. Again, write us about this at info@internetguru.io to discuss how much you want to pay and how much maintenance we can offer in return.

Thanks for your support!

License

MIT License

0.6.1

1 year ago

0.4.0

4 years ago

0.3.0

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago