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

sabuy-fullpage

v1.0.19

Published

full page scrolling for react

Downloads

7

Readme

#Fullpage-React

Demo can be found here

A larger example setup can be found here


####Basic Setup

npm install fullpage-react

Each component from Fullpage-React requires its own block of options ######Component Option Boilerplate

const React = require('react');

const {Fullpage, Slide, TopNav, SideNav} = require('fullpage-react');

let fullPageOptions = {
  // for mouse/wheel events
  // represents the level of force required to generate a slide change on non-mobile, 100 is default
  threshold: 100,

  // for touchStart/touchEnd/mobile scrolling
  // represents the level of force required to generate a slide change on mobile, 100 is default
  sensitivity: 100
};

let topNavOptions = {
  footer: false, //topNav can double as a footer if true
  align: 'left', //also supports center and right alignment

  //styles to apply to children
  activeStyles: {backgroundColor: 'white'},
  hoverStyles: {backgroundColor: 'yellow'},
  nonActiveStyles: {backgroundColor: 'gray'}
};

// all children are spans by default, for stacked buttons,
// just wrap your nested components/buttons in divs
let sideNavOptions = {
  right: '2%', //left alignment is default
  top: '50%', //top is 50% by default

  //styles to apply to children
  activeStyles: {color: 'white'},
  hoverStyles: {color: 'yellow'},
  nonActiveStyles: {color: 'gray'}
};

######Fullpage Component Boilerplate

The Component Itself Allows all content to be placed within Slide components as well as whatever iterators you want for TopNav and SideNav.

NOTE: In the render method, navCount should equal the same amount of Slides you wish to use in order to ensure proper nav click/hover behavior

class FullpageReact extends React.Component {
  constructor(props) {
    super(props)
    this.state = {active: 0};

    this.updateActiveState = this.updateActiveState.bind(this);
  }

  updateActiveState(newActive) {
    this.setState({'active': newActive});
  }

  shouldComponentUpdate(nP, nS) {
    //ensure hoverStyles and activeStyles update
    return nS.active != this.state.active;
  }

  onMouseOver(idx) {
    this.setState({'hover': idx});
  }

  onMouseOut(e) {
    this.setState({'hover': null});
  }

  compareStyles(component, idx) {
    return idx == this.state.active ? component.activeStyles : idx == this.state.hover ? component.hoverStyles : component.nonActiveStyles
  }

  render() {
    let navCount = 3;
    let navArr = [];
    for (let i = 0; i < navCount; i++) {
      navArr.push(i);
    }

    return (
      <Fullpage active={this.updateActiveState}>

        <TopNav {...topNavOptions}>
          {navArr.map((n, idx) => {
            return <span key={idx} ref={idx}>Slide {idx}</span>
          }, this)}
        </TopNav>

        <Slide style={{backgroundColor: '#61DAFB'}}>
          <div id="title">Fullpage React</div>
        </Slide>
        <Slide style={{backgroundColor: '#2B2C28'}}></Slide>
        <Slide style={{backgroundColor: '#EFCB68'}}></Slide>

        <SideNav {...sideNavOptions}>
          {navArr.map((n, idx) => {
            return <div key={idx} ref={idx}>&#x25CF;</div>
          }, this)}
        </SideNav>

      </Fullpage>
    );
  }
};

module.exports = FullpageReact;

######Rendering/Customization Active/Hover state can be applied either functionally like in this demo, or just by passing classNames or Ids to your iterators.

example: This method works for those that prefer to change user interaction with Nav within react itself.

<TopNav className='topNav' {...topNavOptions}>
  {navArr.map((n, idx) => {
    return <span key={idx} ref={idx} style={this.compareStyles(topNavOptions, idx)}
      onMouseOver={() => this.onMouseOver(idx)} onMouseOut={() => this.onMouseOut()}>Slide {idx}</span>
  }, this)}
</TopNav>

But this works just fine too, if you'd rather handle it from the DOM/CSS

<TopNav className='topNav' {...topNavOptions}>
  {navArr.map((n, idx) => {
    return <span className="topNavButton" key={idx} ref={idx}>Slide {idx}</span>
  }, this)}
</TopNav>

//CSS
.topNavButton:hover {
  color: green;
}

Each Component from Fullpage-React contains a class to grab after render by default but these can be overridden.

<TopNav className='myCustomTopNav' {...topNavOptions}> //defaults to 'topNav' if none is provided
  {navArr.map((n, idx) => {
    return <span key={idx} ref={idx}>Slide {idx}</span>
  }, this)}
</TopNav>

####Roadmap

  • Implement horizontal sliders
  • UI Tests