Coder Social home page Coder Social logo

bkwld / nuxt-page-transition-and-anchor-handler Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 1.0 57 KB

Scroll to top before page transition, handle anchor links, and cross-dissolve between pages

License: MIT License

JavaScript 95.63% CSS 4.37%
nuxtjs

nuxt-page-transition-and-anchor-handler's Introduction

nuxt-page-transition-and-anchor-handler

This package add animated scrolling to all anchor links using scrollTo. It also adds a default cross-dissolve page transition which feels faster than the normal Nuxt out-in transition. This works best when you do the second step of Install, making the page scroll to top before the transition starts.

Install

  1. yarn add nuxt-page-transition-and-anchor-handler or npm install nuxt-page-transition-and-anchor-handler
  2. Add nuxt-page-transition-and-anchor-handler to your modules array

If you need to support browsers that don't support ScrollToOptions give smoothscroll-polyfill a shot.

Options

Can be set with the module or in the config file under the ptah key.

  • css (true) - Include the default transition styles (see transition.css)
  • scrollToTopBeforePageChange (true) - Whether to explicitly and smoothly scroll to top before the page change transition.
  • initialDelay (500) - How long to wait after the window.onNuxtReady event before handling the initial page anchor. This gives the page a chance to render the elements you are trying to scroll to.
  • afterPageChangeDelay (0) - How long to wait after a page changing event before handling the page anchor.
  • anchorSelector ([data-anchor={{anchor}}]) - The selector to scroll to. {{anchor}} will be replaced with the URL hash (minus the '#').
  • transition (see source code) - The Nuxt transition object

Methods

These methods are injected globally:

  • this.$scrollTo(target) - Target can be a number or a DOM element
  • this.$scrollToTop() - Shorthand for this.$scrollTo(0)
  • this.$scrollComplete() - Returns a Promise that resolves when the current scroll finishes
  • this.$setVerticalOffset() - Set the vertical offset. You might use this when the header height changes responsively.

nuxt-page-transition-and-anchor-handler's People

Contributors

dependabot[bot] avatar scorichards avatar weotch avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jonjahr

nuxt-page-transition-and-anchor-handler's Issues

Suggestions

If I might offer some suggestions regarding documentation:

  • It could be useful to mention the npm command to install the module (npm install ...)
  • After adding the async function I got an error "Cannot set property 'isTransitioning' of undefined"; should more be done?
  • Would it be possible to add an example or more description to this text "Can be set with the module or in the config file under the ptah key"?
  • Would it be possible to add some more text regarding the different options and methods?
  • would it be possible to add some small example of the usage?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.