Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-gemini-scrollbar

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-gemini-scrollbar

Vue component for custom scrollbars with native scrolling

  • 1.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
76
decreased by-39.2%
Maintainers
1
Weekly downloads
 
Created
Source

vue-gemini-scrollbar

license Travis Vue 2.x

NPM

查看demo

介绍

  • 基于gemini-scrollbar封装的vue组件
  • 基于原生滚动的自定义滚动条
  • 支持IE9+

安装

npm i vue-gemini-scrollbar --save

如需script方式引入,请自行编译,build后在disk文件夹(vue-gemini-scrollbar.js)

npm run build

Attributes

参数类型默认值说明
autoCreateBooleantrue自动创建自定义滚动条
autoshowBooleanfalsehover时才显示滚动条
forceGeminiBooleanfalse原生滚动条可见的情况下,强制显示自定义滚动条(开发时会比较有用)
minThumbSizeNumber20滚动条最小长度

注意: createElements参数在这里被强制置为false,不可配置,因为启用它可能会影响Vue的virtual DOM。

Events

事件名称回调参数说明
readygeminiScrollbarGeminiScrollbar实例创建
resize-滚动区域大小调整时触发

Methods

方法名称说明
create创建滚动区域
update重新计算滚动区域大小(一般不需要你这么做,如果发现滚动区域大小变化导致显示不正常,可以尝试调用它)
destroy移除绑定事件及滚动条元素

使用

安装组件

import Vue from 'vue'
import GeminiScrollbar from 'vue-gemini-scrollbar'

Vue.use(GeminiScrollbar)

在模板中使用

<GeminiScrollbar
    class="my-scroll-bar">
    content...
</GeminiScrollbar>

注意:只有内容溢出才会有滚动效果

.my-scroll-bar{
    height:200px;
}

添加自己的滚动条样式

/* override gemini-scrollbar default styles */

/* vertical scrollbar track */
.gm-scrollbar.-vertical {
  background-color: #f0f0f0
}

/* horizontal scrollbar track */
.gm-scrollbar.-horizontal {
  background-color: transparent;
}

/* scrollbar thumb */
.gm-scrollbar .thumb {
  background-color: rebeccapurple;
}
.gm-scrollbar .thumb:hover {
  background-color: fuchsia;
}

如何为body设置自定义滚动条

因为vue组件的根元素不能为body,此时可以从Vue.$geminiScrollbar访问到GeminiScrollbar对象,然后你就可以自由使用它了(文档请参考:gemini-scrollbar)。

html {
    height: 100%;
    /* or */
    height: 100vh;
}
var scrollbar = new Vue.$geminiScrollbar({
    element: document.body
}).create();

其他实现

Keywords

FAQs

Package last updated on 24 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc