npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@craftkit/craft-widget-stickyheadernavi

v3.2.2

Published

Sticky header navigation system with parallax scrolling effect, for both browser and PWA.

Downloads

15

Readme

Craft-Widget-StickyHeaderNavi

Sticky header navigation system with parallax scrolling effect, for both browser and PWA.

Try online tutorial:
https://github.com/craftkit/craftkit-playground

Feature

  • Sticky header shrinked by scroll
  • Back button for standalone mode (web app added to the home screen)
  • Support for safe-area-inset-*
  • Depends on Craft-UIKit.

How to use

Direct use:

<script src="https://unpkg.com/@craftkit/craft-uikit/dist/craft-uikit.min.js"></script>
<script src="https://unpkg.com/@craftkit/craft-widget-stickyheadernavi/dist/craft-widget-stickyheadernavi.min.js"></script>
<script>
    window.onload = function(){
        Craft.Core.Bootstrap.boot(App);
    };
</script>

or webpack style:

import * as Craft from '@craftkit/craft-uikit';
import * as StickyHeaderNavi from '@craftkit/craft-widget-stickyheadernavi';

Craft.usePackage(StickyHeaderNavi);

export class PageController extends Craft.Widget.StickyHeaderNavi.ViewController { ... }

How to implement your Header

Header constructor requires 2 element, one is Large view, one is Small view. Header starts in Large view, and when you scrolled over Sticky threshold, Small View is shown.

You can implement your Header as a sub-class of Craft.Widget.StickyHeaderNavi.Header abstruct class.

class MyHeader extends Craft.Widget.StickyHeaderNavi.Header {}

let header = new MyHeader({
    large : new LargeTitle(),
    small : new SmallTitle()
}),

The abstruct class implements several interface to support sticky behaviour with some restriction. You have to define height of your Large View and Small View in its style for .root class element. Because the Small View (or sometimes Large View if in the state of scrolled) is not in the DOM until it enabled.

like this:

class Title extends Craft.UI.View { ... }

class LargeTitle extends Title {
    style(componentId){
        return super.style(componentId) + `
            .root { height: 88px; }
        `;
    }
}
class SmallTitle extends Title {
    style(componentId){
        return super.style(componentId) + `
            .root { height: 44px; }
        `;
    }
}

If you want to make dynamically rendered Large and Small View, you have to override below method. See JSDoc comment for details.

| Item | Method | Description | |:-----------------|:-------------------|:------------| | Large height | getLargeHeight | The height of large view should be defined in its root style. | | Small height | getSmallHeight | The height of small view should be defined in its root style. | | Sticky threshold | getStickyThreshold | Threshold of scroll amount to make header sticky |

Events your header may handle

| Event | Description | |:----------------------|:-------------------------------------------------| | onEnterSticky | called when the page scrolled to sticky height.By default, when scrolled over sticky amount, large view is hidden and small view is shown. | | onExitSticky | called when the page scroll backed to top areaBy default, when scroll back to top area less than sticky height, large view is shown and small view is hidden. | | onAppearBackButton | called when the back button appearedBy default, both large and small view will slide out 44px (defined in .slide_out css class). | | onDisappearBackButton | called when the back button disappearedBy default, both large and small view will turn back to the original position (defined in .slide_in css class). |

License

MIT