Code Monkey home page Code Monkey logo

vue-fullpage's Introduction

fullpage-vue

A sigle-page scroll plugin based on [email protected],support for mobile and PC . 中文版

overview

To achieve sigle-page scroll in mobile, support horizontal scroll and vertical scroll, support all the animation instructions of animate.css.

Online demo

here's a jsfiddle demo Live demo

Installation

npm install fullpage-vue --save

If you want use animate instruction, please install animate.css

npm install animate.css --save

animate.css usage

Document

options

  • start : (default:0) Display first page
  • duration : (default:500)
  • loop : (default:false)
  • dir : (default:v) Direction of movement
  • der : (default:0.1)
  • movingFlag : (default:false)
  • beforeChange : (default:function) Before change callback
  • afterChange : (default:function) After change callback
  • overflow : (default:hidden) hidden || scroll || auto hidden Hidden overflow scroll Handling the scroll bars of page auto Handling all scroll bars in page,Start checking from triggered elements
  • disabled : (default:false)

method

moveTo

Move to the specified page

  /**
   *
   * @param {Number} moveToIndex Move to index
   * @param {Boolean} animated Animated move?
   * @param {Boolean} force Fore move default:false
   */
  $fullpage.moveTo(1/*move to index*/,false /*animatied*/,true /*force move?*/)

movePrev

Move to the previous page

moveNext

Move to the next page

setDisabled

Change the value of disabled. A value of true disables move

$update

Update the dom structure,for example v-for and v-if Affect the number of pages, need to manually call $update

  <button type="button" 
    v-for="btn in pageNum"
    :class="{active:index == btn + 2}" 
    @click="moveTo(btn+2)">page {{btn+2}}</button>
  <button type="button" @click="showPage()">add page</button>

  <div class="page-2 page" v-for="page in pageNum">
    <h2 class="part-2" v-animate="{value: 'bounceInRight'}">page {{page}}</h2>
  </div>
    showPage:function(){
      this.pageNum ++;
      this.$refs.fullpage.$fullpage.$update();
    }

getting started

main.js

Import the plugin of css and js file in main.js

import 'animate.css'
import 'fullpage-vue/src/fullpage.css'
import VueFullpage from 'fullpage-vue'
Vue.use(VueFullpage)

app.vue

template

fullpage-containerfullpage-wppageare default class name. Add the v-fullpage command to the page-wp container. Add the v-animate command to the page container.

<div class="fullpage-container">
  <div class="fullpage-wp" v-fullpage="opts" ref="example">
    <div class="page-1 page">
      <p class="part-1" v-animate="{value: 'bounceInLeft'}">fullpage-vue</p>
    </div>
    <div class="page-2 page">
      <p class="part-2" v-animate="{value: 'bounceInRight'}">fullpage-vue</p>
    </div>
    <div class="page-3 page">
      <p class="part-3" v-animate="{value: 'bounceInLeft', delay: 0}">fullpage-vue</p>
      <p class="part-3" v-animate="{value: 'bounceInRight', delay: 600}">fullpage-vue</p>
      <p class="part-3" v-animate="{value: 'zoomInDown', delay: 1200}">fullpage-vue</p>
    </div>
  </div>
  <button @click="moveNext">next</button>
</div>

script

fullpage-vue value please refer to api document

export default {
  data() {
    return {
      opts: {
        start: 0,
        dir: 'v',
        duration: 500,
        beforeChange: function (currentSlideEl,currenIndex,nextIndex) {
        },
        afterChange: function (currentSlideEl,currenIndex) {
        }
      }
    }
  },
  methods:{
    moveNext(){
      this.$refs.example.$fullpage.moveNext(); //Move to the next page
    }
  }
}

style

Set the page-container container's width and height what do you want, and the v-fullpage command will adapt the width and height of the parent element. The following settings allow the scrolling page to fill the full screen.

<style>
.fullpage-container {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}
</style>

vue-fullpage's People

Contributors

17881055 avatar abel-oye avatar bmpenuelas avatar ralmaz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

vue-fullpage's Issues

Two Instances of vue-fullpage

Is it possible to have two separate instances of the plugin .? I have a situation where it has to be used in two separate div. Any input is appreciated.

License

Is there a license to this plugin.? I had a look and could not find something.

cancel loop scroll still cause the index change

Suppose we have this requirement:

  • This is a loop scroll application.
  • It can only loop from the end to the start

Then I'm going to cancel the scroll event when it scroll from the start to the end. This is my beforeChange callback function.

beforeChange: function (el, prev, next) {
  console.log('brefore', prev, next)
  if (prev === 2 && next === 2) {
    return false
  }
  console.log('after', prev, next)
}

See JSFiddle demo: https://jsfiddle.net/z4Lvwhr6/

Once open, scroll up for twice, there will be there logs in the console:

brefore 2 2 // no scroll happened, still in page1
brefore 2 1 // scroll from page1 to page2
after 2 1

mouse left click AND moveTo has no animation

Sup, I'm coding a slide site, and I need to "block" the switch of pages of the left click of mouse, I just want to switch the page with the scroll. The other issue is that the moveTo function is not working properly, I have a menu aSide that calls a event, that also calls the moveTo function. (I hope you can get it, I'm brazilian)

                     <li>
                        <a @click="moveTo(0, 'sobre')">
                            <span>
                                Sobre
                            </span>
                        </a>
                    </li>
mounted() {
            Event.$on('move-to', this.moveTo , this.slide)
            this.moveTo();
        },

methods: {
            moveTo(slide) {
                this.$refs.fpcontainer.$fullpage.moveTo(slide);
            }
        },

[Bug] Scroll on mouse move event

I scrolled up and down a few times and then suddenly when I move my mouse horizontal the page scrolls.

does anyone has the same problem?

#Version

  • vue: 2.6.12
  • fullpage-vue: 2.1.1

More instructions

Hello,
can you provide more instructions about plugin?

For example, how to make menu work. I add @click="moveTo(2)", but no action and I receive error (method "moveTo" is not defined on the instance but referenced during render).

It is not clear how to fix this.

Mobile scroll issue

Hi I am using your plugin on my charity project which I really like.

http://www.shekinahgloryacademy.co.ke/

It works perfectly on desktop but mobile. I can't scroll unless touching the little green navigation dots on right hand side.

It's great if you can help me fix this one out.

Many thanks

how move to page after page reloading

After reloading page, it`s default starts on first page, but how to scroll to the page on which the user reloaded the page. I had a solution with a cookie, but its doesnt work..

mounted() {
     this.$refs.fullpage.$fullpage.moveTo(2);
}

that doesnt work..

wechat scroll problem

set overflow 'scroll' will make the page unscrollable in WeChat
tested in MIUI 9(android 7.1) and wechat devtool(0.7.0) on PC

运行不了

node install

node-pre-gyp ERR! Tried to download(404): https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.1.2/fse-v1.1.2-node-v67-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v67 ABI) (falling back to source compile with node-gyp)
node-pre-gyp ERR! Tried to download(undefined): https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.1.2/fse-v1.1.2-node-v67-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v67 ABI) (falling back to source compile with node-gyp)

page scroll time for translate effect

a question rather:
how do you make use of translate effect between two images while scrolling on the same page? => how to set scrolling time/distance one the same page?
thanks for extension

How to catch down or up event

  1. I want to catch event and input my custom event, when mousewheel down or up.
    How I can do it? Thank you.

  2. I want to know option's movingFlag description. how to use movingFlag data?

moveTo isn't working for the last slide

I'm using the function moveTo to redirect to specifcs slides in my page. For example, if the url is /slide3, the page starts with slide number 3, but if the number 3 is the last it bugs and loads the first slide.

vue-fullpage可以嵌套使用吗?

比如我在第二屏里再嵌套一组横向滚动的页面,但是我看配置项里没有指定DOM节点这一项,现在是不能嵌套的吧!

moveTo without animation

When animation is set to false in moveTo() then there is no action in

            addEventListener(el, 'webkitTransitionEnd', function () {
                _this2.toogleAnimate(_this2.curIndex);
                _this2.opts.afterChange.call(_this2, _this2.pageEles[_this2.curIndex], _this2.curIndex);
                _this2.opts.movingFlag = false;
            });

which mean movingFlag is still set to true and it's returning from mousemove on the begining of action.
I propose to add that.opts.movingFlag = false; to mouseup. Then it works fine but I didn't analize all code.

 addEventListener(el, 'mouseup', function (e) {
                    isMousedown = false;
                    that.opts.movingFlag = false;
                });

Component crash when Vue.js devtools is open

Hi,

Strange bug but when you are in dev mode with webpack and vue-cli and open Vue dev tools component crash.

To reproduce :

  • Open local url
  • Open Chrome Dev tools
  • Open Vue dev tools and switch to 'Events' tabs.

The component doesn't work anymore.
I don't know if it's related with the events emitted by the component ?

callback function problem

Hi, this tool is awesome, thank you for your working on vue-fullpage. I found some problems while using it.

I start with the options from README:

export default {
  data() {
    return {
      opts: {
        start: 0,
        dir: 'v',
        duration: 500,
        beforeChange: function (prev, next) {
        },
        afterChange: function (prev, next) {
        }
      }
    }
  },
  method:{
    moveNext(){
      this.$refs.example.$fullpage.moveNext(); //Move to the next page
    }
  }
}

When I look into beforeChange function, prev is a DOM object, I think the parameters should be beforeChange: function (html, prev, next)

你好,firefox下滚动无反应,我本地已做修改

你好,看了你的代码,你的鼠标滚轮监听的是mousewheel,在firefox有问题,我把监听的mousewheel修改为
(("onwheel" in document.createElement("div")) ? "wheel" :(document.onmousewheel !== undefined ? "mousewheel" : "DOMMouseScroll")) 然后就可以兼容firefox了,望你这边修改下代码,重新发个包

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.