@spaas/scrollbar
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "@spaas/scrollbar", | ||
"version": "1.0.0", | ||
"description": "覆盖原有的滚动条样式", | ||
"version": "1.0.1", | ||
"description": "基于elementUI的滚动条组件", | ||
"license": "MIT", | ||
"keywords": [ | ||
"ice", | ||
"vue", | ||
"component" | ||
], | ||
"files": [ | ||
@@ -11,31 +17,65 @@ "src/", | ||
], | ||
"license": "MIT", | ||
"keywords": [ | ||
"ice", | ||
"vue", | ||
"block" | ||
], | ||
"main": "dist/index.umd.js", | ||
"module": "dist/index.esm.js", | ||
"unpkg": "dist/index.min.js", | ||
"browser": { | ||
"./sfc": "src/index.vue" | ||
}, | ||
"scripts": { | ||
"start": "vue-cli-service serve", | ||
"build": "vue-cli-service build", | ||
"lint": "vue-cli-service lint", | ||
"start": "vue-styleguidist server", | ||
"doc": "vue-styleguidist build", | ||
"build": "npm run build:unpkg & npm run build:es & npm run build:umd", | ||
"build:umd": "rollup --config build/rollup.config.js --format umd --file dist/index.umd.js", | ||
"build:es": "rollup --config build/rollup.config.js --format es --file dist/index.esm.js", | ||
"build:unpkg": "rollup --config build/rollup.config.js --format iife --file dist/index.min.js", | ||
"precommit": "pretty-quick --staged", | ||
"stdver": "standard-version -m '[skip ci] chore(release): v%s'", | ||
"release": "gren release --override", | ||
"screenshot": "ice-devtools screenshot", | ||
"prepublishOnly": "npm run build" | ||
"prepublishOnly": "npm run build && npm run screenshot" | ||
}, | ||
"dependencies": { | ||
"@femessage/theme-deepexi": "^2.4.11", | ||
"element-ui": "^2.4.11", | ||
"rollup-plugin-less": "^1.1.2", | ||
"rollup-plugin-node-resolve": "^5.1.0", | ||
"vue": "^2.5.16" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.4.3", | ||
"@babel/plugin-transform-runtime": "^7.4.3", | ||
"@babel/preset-env": "^7.4.3", | ||
"@vue/babel-helper-vue-jsx-merge-props": "^1.0.0", | ||
"@vue/babel-plugin-transform-vue-jsx": "^1.0.0", | ||
"@vue/babel-preset-jsx": "^1.0.0", | ||
"@vue/cli-plugin-babel": "^3.4.0", | ||
"@vue/cli-plugin-eslint": "^3.4.0", | ||
"@vue/cli-service": "^3.4.0", | ||
"babel-eslint": "^10.0.1", | ||
"babel-loader": "^8.0.5", | ||
"babel-plugin-external-helpers": "^6.22.0", | ||
"babel-plugin-transform-vue-jsx": "^3.7.0", | ||
"babel-preset-env": "^1.7.0", | ||
"babel-preset-es2015-rollup": "^3.0.0", | ||
"babel-preset-latest": "^6.24.1", | ||
"eslint": "^5.8.0", | ||
"eslint-plugin-vue": "^5.0.0", | ||
"vue-template-compiler": "^2.5.21", | ||
"file-loader": "^3.0.1", | ||
"github-release-notes": "^0.17.0", | ||
"glob": "^7.1.3", | ||
"husky": "^0.14.3", | ||
"less": "^3.9.0", | ||
"less-loader": "^5.0.0" | ||
"less-loader": "^5.0.0", | ||
"minimist": "^1.2.0", | ||
"prettier": "1.12.1", | ||
"pretty-quick": "^1.4.1", | ||
"rollup": "^1.9.0", | ||
"rollup-plugin-babel": "^4.3.2", | ||
"rollup-plugin-buble": "^0.19.6", | ||
"rollup-plugin-commonjs": "^9.3.4", | ||
"rollup-plugin-replace": "^2.2.0", | ||
"rollup-plugin-terser": "^4.0.4", | ||
"rollup-plugin-vue": "^4.7.2", | ||
"standard-version": "^6.0.1", | ||
"vue-loader": "^15.7.0", | ||
"vue-styleguidist": "3.11.4", | ||
"vue-template-compiler": "^2.5.16", | ||
"webpack": "^4.29.6" | ||
}, | ||
@@ -56,8 +96,9 @@ "eslintConfig": { | ||
}, | ||
"blockConfig": { | ||
"componentConfig": { | ||
"name": "scrollbar", | ||
"title": "滚动条", | ||
"title": "滚动条组件", | ||
"categories": [ | ||
"列表", | ||
"数据展示", | ||
"其他" | ||
"信息展示" | ||
], | ||
@@ -64,0 +105,0 @@ "screenshot": "" |
@@ -1,5 +0,54 @@ | ||
# xpaas-materilas-scrollbar | ||
# @spaas/scrollbar | ||
简介:滚动条 | ||
![截图](./screenshot.png) | ||
覆盖原有的滚动条样式 | ||
项目简要说明 + 示例图 | ||
## Table of Contents | ||
- [Introduction](#introduction) | ||
- [Feature](#feature) | ||
- [Demo](#demo) | ||
- [Install](#install) | ||
- [Example](#example) | ||
- [Reference](#reference) | ||
- [Contributors](#contributors) | ||
- [License](#license) | ||
## Introduction | ||
[⬆ Back to Top](#table-of-contents) | ||
## Feature | ||
[⬆ Back to Top](#table-of-contents) | ||
[⬆ Back to Top](#table-of-contents) | ||
## Install | ||
[⬆ Back to Top](#table-of-contents) | ||
## Example | ||
[⬆ Back to Top](#table-of-contents) | ||
## Reference | ||
[⬆ Back to Top](#table-of-contents) | ||
## Contributors | ||
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): | ||
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> | ||
<!-- prettier-ignore --> | ||
<!-- ALL-CONTRIBUTORS-LIST:END --> | ||
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! | ||
[⬆ Back to Top](#table-of-contents) | ||
## License | ||
[MIT](./LICENSE) | ||
[⬆ Back to Top](#table-of-contents) |
163
src/index.js
@@ -1,141 +0,32 @@ | ||
// reference https://github.com/noeldelgado/gemini-scrollbar/blob/master/index.js | ||
// Import vue component | ||
import Component from './index.vue' | ||
import {addResizeListener, removeResizeListener} from './utils/resize-event' | ||
import scrollbarWidth from './utils/scrollbar-width' | ||
import {toObject} from './utils/util' | ||
import Bar from './bar.js' | ||
import './index.less' | ||
// install function executed by Vue.use() | ||
export function install(Vue) { | ||
if (install.installed) return | ||
install.installed = true | ||
Vue.component("Scrollbar", Component) | ||
} | ||
/* istanbul ignore next */ | ||
export default { | ||
name: 'ScrollbarMain', | ||
// Create module definition for Vue.use() | ||
const plugin = { | ||
install | ||
} | ||
components: {Bar}, | ||
// To auto-install when vue is found | ||
let GlobalVue = null | ||
if (typeof window !== 'undefined') { | ||
GlobalVue = window.Vue | ||
} else if (typeof global !== 'undefined') { | ||
GlobalVue = global.Vue | ||
} | ||
if (GlobalVue) { | ||
GlobalVue.use(plugin) | ||
} | ||
props: { | ||
horizontal: { | ||
type: Boolean, | ||
default: false | ||
}, // 是否显示横向滚动条 | ||
vertical: { | ||
type: Boolean, | ||
default: true | ||
}, // 是否显示竖向滚动条 | ||
wrapStyle: {}, | ||
wrapClass: {}, | ||
viewClass: {}, | ||
viewStyle: {}, | ||
noresize: { | ||
type: Boolean, | ||
default: true | ||
} | ||
}, | ||
// To allow use as module (npm/webpack/etc.) export component | ||
export default Component | ||
data() { | ||
return { | ||
sizeWidth: '0', | ||
sizeHeight: '0', | ||
moveX: 0, | ||
moveY: 0 | ||
} | ||
}, | ||
computed: { | ||
wrap() { | ||
return this.$refs.wrap | ||
}, | ||
slotsWrap() { | ||
return this.$refs.slotsWrap | ||
} | ||
}, | ||
render(h) { | ||
let gutter = scrollbarWidth() | ||
let style = this.wrapStyle | ||
if (gutter) { | ||
const gutterWith = `-${gutter}px` | ||
const gutterStyle = `${ | ||
this.horizontal ? `margin-bottom: ${gutterWith}; ` : '' | ||
}${this.vertical ? `margin-right: ${gutterWith};` : ''}` | ||
if (Array.isArray(this.wrapStyle)) { | ||
style = toObject(this.wrapStyle) | ||
style.marginRight = style.marginBottom = gutterWith | ||
} else if (typeof this.wrapStyle === 'string') { | ||
style += gutterStyle | ||
} else { | ||
style = gutterStyle | ||
} | ||
} | ||
const wrap = ( | ||
<div | ||
ref="wrap" | ||
style={style} | ||
onScroll={this.handleScroll} | ||
class={[ | ||
this.wrapClass, | ||
'scrollbar__wrap', | ||
gutter ? '' : 'scrollbar__wrap--hidden-default' | ||
]} | ||
> | ||
{ | ||
<div | ||
class={['scrollbar__view', this.viewClass]} | ||
style={this.viewStyle} | ||
ref="resize" | ||
> | ||
<div ref="slotsWrap">{this.$slots.default}</div> | ||
</div> | ||
} | ||
</div> | ||
) | ||
let nodes = [wrap] | ||
if (this.horizontal) { | ||
nodes.push(<Bar move={this.moveX} size={this.sizeWidth} />) | ||
} | ||
if (this.vertical) { | ||
nodes.push(<Bar vertical move={this.moveY} size={this.sizeHeight} />) | ||
} | ||
return h('div', {class: 'scrollbar'}, nodes) | ||
}, | ||
methods: { | ||
handleScroll() { | ||
const wrap = this.wrap | ||
const slotsWrap = this.slotsWrap | ||
this.moveY = (wrap.scrollTop * 100) / wrap.clientHeight | ||
this.moveX = (wrap.scrollLeft * 100) / wrap.clientWidth | ||
const bottomDistance = | ||
slotsWrap.clientHeight - wrap.scrollTop - wrap.clientHeight | ||
const rightDistance = | ||
this.$refs.slotsWrap.clientHeight - wrap.scrollLeft - wrap.clientWidth | ||
this.$emit('onScrollY', bottomDistance) | ||
this.$emit('onScrollX', rightDistance) | ||
}, | ||
update() { | ||
let heightPercentage, widthPercentage | ||
const wrap = this.wrap | ||
if (!wrap) return | ||
heightPercentage = (wrap.clientHeight * 100) / wrap.scrollHeight | ||
widthPercentage = (wrap.clientWidth * 100) / wrap.scrollWidth | ||
this.sizeHeight = heightPercentage < 100 ? heightPercentage + '%' : '' | ||
this.sizeWidth = widthPercentage < 100 ? widthPercentage + '%' : '' | ||
} | ||
}, | ||
mounted() { | ||
this.$nextTick(this.update) | ||
!this.noresize && addResizeListener(this.$refs.slotsWrap, this.update) | ||
}, | ||
beforeDestroy() { | ||
!this.noresize && removeResizeListener(this.$refs.slotsWrap, this.update) | ||
} | ||
} | ||
// It's possible to expose named exports when writing components that can | ||
// also be used as directives, etc. - eg. import { RollupDemoDirective } from 'rollup-demo'; | ||
// export const RollupDemoDirective = component; |
@@ -7,3 +7,3 @@ import ResizeObserver from 'resize-observer-polyfill' | ||
const resizeHandler = function(entries) { | ||
for (let entry of entries) { | ||
Object.values(entries).forEach(entry => { | ||
const listeners = entry.target.__resizeListeners__ || [] | ||
@@ -15,3 +15,3 @@ if (listeners.length) { | ||
} | ||
} | ||
}) | ||
} | ||
@@ -18,0 +18,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55
71755
5
36
13
1784
1
+ Addedrollup-plugin-less@^1.1.2
+ Added@femessage/theme-deepexi@2.4.11(transitive)
+ Added@rollup/rollup-android-arm-eabi@4.27.0(transitive)
+ Added@rollup/rollup-android-arm64@4.27.0(transitive)
+ Added@rollup/rollup-darwin-arm64@4.27.0(transitive)
+ Added@rollup/rollup-darwin-x64@4.27.0(transitive)
+ Added@rollup/rollup-freebsd-arm64@4.27.0(transitive)
+ Added@rollup/rollup-freebsd-x64@4.27.0(transitive)
+ Added@rollup/rollup-linux-arm-gnueabihf@4.27.0(transitive)
+ Added@rollup/rollup-linux-arm-musleabihf@4.27.0(transitive)
+ Added@rollup/rollup-linux-arm64-gnu@4.27.0(transitive)
+ Added@rollup/rollup-linux-arm64-musl@4.27.0(transitive)
+ Added@rollup/rollup-linux-powerpc64le-gnu@4.27.0(transitive)
+ Added@rollup/rollup-linux-riscv64-gnu@4.27.0(transitive)
+ Added@rollup/rollup-linux-s390x-gnu@4.27.0(transitive)
+ Added@rollup/rollup-linux-x64-gnu@4.27.0(transitive)
+ Added@rollup/rollup-linux-x64-musl@4.27.0(transitive)
+ Added@rollup/rollup-win32-arm64-msvc@4.27.0(transitive)
+ Added@rollup/rollup-win32-ia32-msvc@4.27.0(transitive)
+ Added@rollup/rollup-win32-x64-msvc@4.27.0(transitive)
+ Added@types/estree@1.0.6(transitive)
+ Added@types/node@22.9.0(transitive)
+ Added@types/resolve@0.0.8(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedbuiltin-modules@3.3.0(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedcopy-anything@2.0.6(transitive)
+ Addederrno@0.1.8(transitive)
+ Addedestree-walker@0.2.10.6.1(transitive)
+ Addedfs-extra@0.30.0(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedfsevents@2.3.3(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedgrowl@1.10.5(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedimage-size@0.5.5(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-core-module@2.15.1(transitive)
+ Addedis-module@1.0.0(transitive)
+ Addedis-what@3.14.1(transitive)
+ Addedjsonfile@2.4.0(transitive)
+ Addedklaw@1.3.1(transitive)
+ Addedless@3.13.1(transitive)
+ Addedmake-dir@2.1.0(transitive)
+ Addedmime@1.6.0(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addednative-request@1.1.2(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedpath-parse@1.0.7(transitive)
+ Addedpify@4.0.1(transitive)
+ Addedprr@1.0.1(transitive)
+ Addedresolve@1.22.8(transitive)
+ Addedrimraf@2.7.1(transitive)
+ Addedrollup@0.34.134.27.0(transitive)
+ Addedrollup-plugin-less@1.1.3(transitive)
+ Addedrollup-plugin-node-resolve@5.2.0(transitive)
+ Addedrollup-pluginutils@1.5.22.8.2(transitive)
+ Addedsemver@5.7.2(transitive)
+ Addedsource-map@0.5.7(transitive)
+ Addedsource-map-support@0.4.18(transitive)
+ Addedsupports-preserve-symlinks-flag@1.0.0(transitive)
+ Addedtslib@1.14.1(transitive)
+ Addedundici-types@6.19.8(transitive)
+ Addedwrappy@1.0.2(transitive)