1 Star 1 Fork 1

solocode/vue-seamless-scroll

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
7年前
Loading...
README
MIT

vue-seamless-scroll

A simple, Seamless scrolling for Vue.js

Build Status LICENSE MIT

🐾online demo | 🌾 sample demo | 📘 中文文档

Content

Update log

1.1.17

Bug fix

  • The step attribute is set to a decimal point below 1 and scrolls up with a sway.
  • The offsetWidth is rounded off, causing the error to be calculated. The horizontal scrolling is not on one line, and a blank will appear.
  • If single-step scrolling is set, the step needs to be a single-numbered divisor, otherwise the position of the single-step scrolling end cannot be guaranteed.

Configuration update

  • Added navigation configuration, whether the left and right scrolling shows the controller button. When the value is true, autoPlay automatically becomes false.

Browser support

IE
IE
Firefox
Firefox
Chrome
Chrome
Safari
Safari
iOS Safari
iOS
Chrome for Android
Android
IE9+

Features

  • base on requestAnimationFrame.
  • the configuration meets a variety of requirements.
  • current support for seamless scrolling, single-step scrolling, and manual switching support for horizontal direction.

Installation

NPM

npm install vue-seamless-scroll --save

CDN

https://cdn.jsdelivr.net/npm/vue-seamless-scroll@1.1.17/dist/vue-seamless-scroll.min.js

Usage

ES6

online demo

// **main.js**
// 1.global install
import Vue from 'vue'
import scroll from 'vue-seamless-scroll'
Vue.use(scroll)

//or you can set componentName default componentName is vue-seamless-scroll
Vue.use(scroll,{componentName: 'scroll-seamless'})

// 2.single .vue import
<script>
  import vueSeamless from 'vue-seamless-scroll'
   export default {
      components: {
        vueSeamless
      }
   }
</script>

Normal use

Example:

Specific reference test/test.html

<html>
<head>
  ...
</head>
<body>
  <div id="app">
    <vue-seamless-scroll></vue-seamless-scroll>
  </div>
  <script src="vue.js"></script>
  <script src="vue-seamless-scroll"></script>
  <script>
    new Vue({
      el: '#app'
    })
  </script>
</body>
</html>

Configure

key description default val
step the faster the rolling speed is faster 1 Number
limitMoveNum start seamless scrolling minimum data length 5 Number
hoverStop mouse hover control is enabled true Boolean
direction 0 down、 1 up 、 2 left 、 3 right 1 Number
openTouch open mobile touch true Boolean
singleHeight one single stop height(default zero is seamless) => direction 0/1 0 Number
singleWidth one single stop width(default zero is seamless) => direction 2/3 0 Number
waitTime one single data stop wait time(ms) 1000 Number
switchOffset the left and right buttons distance from the left and right sides (px) 30 Number
autoPlay Less than 1.1.17 version needs to be set to false when manually switching true Boolean
switchSingleStep the size of a single step switch (px) 134 Number
switchDelay the animation time of a single step switch(ms) 400 Number
switchDisabledClass the className of the switch parent element that cannot be clicked disabled String
isSingleRemUnit singleHeight and singleWidth Whether to enable the rem metric false Boolean
  • update 1.1.17
key description default val
navigation Whether the left and right scrolling shows the controller button, autoPlay automatically becomes false when true false Boolean

CalBackEvents

name description calback params
ScrollEnd A roll-through callback event null

Individual special configuration items

1.The outermost container needs to be set manuallywidth height overflow:hidden

2.The left and right seamless rolling needs to be set for the main content area (that is, the default slot slots)css width(otherwise, the actual width cannot be calculated correctly). You can also set it to display:flex; without setting the css width property.

3.The step value is not recommended to be too small, otherwise there will be carton effect.(If single-step scrolling is set, the step needs to be a divisor of the single-step size, otherwise the position of the single-step scrolling end cannot be guaranteed to be accurate. ~~~~~, such as single step 30, step can not be 4)

4.You need to set when you need to manually switch left and right to scrollautoPlay:false(Starting with version 1.1.17, you only need to set navigation:false),(The loop is not currently supported.)

5.Provides slot left-switch || right-switch you can freely define the button styles you want. The outer div is positioned in the middle,the distance from both sides can be adjusted by the switchOffset parameter.

6.When the button reaches the boundary position, it automatically adds a definition to the state button that cannot be clicked.switchDisabledClass: 'disabled',you can configure it as needed.

Issues solution

Event cannot be duplicated

Changelog

See the GitHub release history.

Cares

If you want js to scroll seamlessly (without dependencies) you can switch to here.seamscroll

Contribution

Welcome to give some Suggestions and optimizations, and look forward to your Pull Request.

License

vue-seamless-scroll is open source and released under the MIT License.

MIT License Copyright (c) 2017 Plug-in unit Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

:beginner:A simple, seamless scrolling for Vue.js vue无缝滚动component 展开 收起
README
MIT
取消

发行版

暂无发行版

贡献者 (4)

全部

近期动态

5年前创建了仓库
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/solocoding/vue-seamless-scroll.git
git@gitee.com:solocoding/vue-seamless-scroll.git
solocoding
vue-seamless-scroll
vue-seamless-scroll
master

搜索帮助