chore(scrollbar): checkpoint

This commit is contained in:
07akioni 2019-07-29 18:24:59 +08:00
parent a981cb981d
commit fcc45b3fcd
2 changed files with 44 additions and 3 deletions

View File

@ -8,7 +8,11 @@
style="flex-wrap: nowrap;"
>
<!--EXAMPLE_START-->
Write some demo here
<div style="width: 400px; height: 300px;">
<n-scrollbar>
<div style="background: linear-gradient(red, blue); width: 100%; height: 500px;" />
</n-scrollbar>
</div>
<!--EXAMPLE_END-->
</div>
<pre class="n-doc-section__inspect">Inspect some value here</pre>

View File

@ -1,9 +1,46 @@
<template>
<div>example</div>
<div
ref="scrollContainer"
class="n-scrollbar"
@scroll="handleScroll"
>
<slot />
</div>
</template>
<script>
export default {
name: 'NScrollBar'
name: 'NScrollbar',
mounted () {
this.$el.parentElement.style.position = 'relative'
this.$el.parentElement.style.overflow = 'hidden'
this.$el.parentElement.classList.add('n-scrollbar-wrapper')
},
methods: {
handleScroll () {
console.log(this.$refs.scrollContainer.scrollTop)
console.log('scroll')
}
}
}
</script>
<style lang="scss" scoped>
.n-scrollbar-wrapper {
}
.n-scrollbar {
width: 100%;
position: absolute;
left: 0;
bottom: 0;
top: 0;
right: 0;
overflow: scroll;
&::-webkit-scrollbar {
width: 0;
height: 0;
}
}
</style>