💄 Site > Code > Hide scrollbar
This commit is contained in:
@@ -19,5 +19,34 @@ export default
|
|||||||
{
|
{
|
||||||
return this.$store.state.projects.current
|
return this.$store.state.projects.current
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
mounted()
|
||||||
|
{
|
||||||
|
this.testScrollbar()
|
||||||
|
},
|
||||||
|
|
||||||
|
methods:
|
||||||
|
{
|
||||||
|
testScrollbar()
|
||||||
|
{
|
||||||
|
// Create dummy
|
||||||
|
const dummy = document.createElement("div")
|
||||||
|
|
||||||
|
dummy.style.width = '100px'
|
||||||
|
dummy.style.height = '100px'
|
||||||
|
dummy.style.overflow = 'scroll'
|
||||||
|
dummy.style.position = 'absolute'
|
||||||
|
dummy.style.top = '-9999px'
|
||||||
|
|
||||||
|
this.$el.appendChild(dummy)
|
||||||
|
|
||||||
|
// Get the scrollbar width
|
||||||
|
const scrollbarWidth = dummy.offsetWidth - dummy.clientWidth
|
||||||
|
this.$store.commit('updateScrollbarWidth', scrollbarWidth)
|
||||||
|
|
||||||
|
// Delete the DIV
|
||||||
|
this.$el.removeChild(dummy)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -32,6 +32,11 @@ export default
|
|||||||
currentLine()
|
currentLine()
|
||||||
{
|
{
|
||||||
return this.$store.state.files.currentLine
|
return this.$store.state.files.currentLine
|
||||||
|
},
|
||||||
|
|
||||||
|
scrollbarWidth()
|
||||||
|
{
|
||||||
|
return this.$store.state.scrollbarWidth
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -17,17 +17,26 @@
|
|||||||
top 30px
|
top 30px
|
||||||
right 0
|
right 0
|
||||||
width 100%
|
width 100%
|
||||||
height 100%
|
bottom 0
|
||||||
font-family Inconsolata, Monaco, Consolas, 'Courier New', Courier
|
font-family Inconsolata, Monaco, Consolas, 'Courier New', Courier
|
||||||
line-height 20px
|
line-height 20px
|
||||||
letter-spacing 0.5px
|
letter-spacing 0.5px
|
||||||
font-size 15px
|
font-size 15px
|
||||||
background #2d2d49
|
background #2d2d49
|
||||||
overflow scroll
|
overflow hidden
|
||||||
|
|
||||||
.version-active &
|
.version-active &
|
||||||
width 75%
|
width 75%
|
||||||
|
|
||||||
|
.scroll-hack
|
||||||
|
position absolute
|
||||||
|
top 0
|
||||||
|
left 0
|
||||||
|
bottom -15px
|
||||||
|
right -15px
|
||||||
|
overflow scroll
|
||||||
|
|
||||||
|
|
||||||
.lines
|
.lines
|
||||||
position absolute
|
position absolute
|
||||||
top 0
|
top 0
|
||||||
@@ -90,7 +99,7 @@
|
|||||||
|
|
||||||
.hljs
|
.hljs
|
||||||
display block
|
display block
|
||||||
overflow-x auto
|
// overflow-x auto
|
||||||
color #abb2bf
|
color #abb2bf
|
||||||
|
|
||||||
.hljs-comment
|
.hljs-comment
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<div class="viewer" v-if="version">
|
<div class="viewer" v-if="version">
|
||||||
|
<div class="scroll-hack" :style="`bottom:-${scrollbarWidth}px;right:-${scrollbarWidth}px;`">
|
||||||
<pre class="code" v-highlightjs="version.content" contenteditable @keydown="onCodeKeyDown($event)"><code :class="[ extension ]"></code></pre>
|
<pre class="code" v-highlightjs="version.content" contenteditable @keydown="onCodeKeyDown($event)"><code :class="[ extension ]"></code></pre>
|
||||||
<div class="lines">
|
<div class="lines">
|
||||||
<div class="line" v-for="line in linesCount" @click.prevent="onLineClick(line)">
|
<div class="line" v-for="line in linesCount" @click.prevent="onLineClick(line)">
|
||||||
@@ -10,3 +11,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
@@ -17,7 +17,8 @@ export default new Vuex.Store({
|
|||||||
|
|
||||||
state:
|
state:
|
||||||
{
|
{
|
||||||
url: ''
|
url: '',
|
||||||
|
scrollbarWidth: 0
|
||||||
},
|
},
|
||||||
|
|
||||||
mutations:
|
mutations:
|
||||||
@@ -25,6 +26,11 @@ export default new Vuex.Store({
|
|||||||
updateUrl(state, data)
|
updateUrl(state, data)
|
||||||
{
|
{
|
||||||
state.url = data
|
state.url = data
|
||||||
|
},
|
||||||
|
|
||||||
|
updateScrollbarWidth(state, data)
|
||||||
|
{
|
||||||
|
state.scrollbarWidth = data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user