💄 Site > Code > Hide scrollbar

This commit is contained in:
brunosimon
2017-09-03 21:29:42 +02:00
parent d9a977cff6
commit b1dc8bb2ee
5 changed files with 63 additions and 12 deletions
+29
View File
@@ -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)
}
} }
} }
+5
View File
@@ -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
} }
}, },
+12 -3
View File
@@ -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
+10 -8
View File
@@ -1,12 +1,14 @@
<div class="viewer" v-if="version"> <div class="viewer" v-if="version">
<pre class="code" v-highlightjs="version.content" contenteditable @keydown="onCodeKeyDown($event)"><code :class="[ extension ]"></code></pre> <div class="scroll-hack" :style="`bottom:-${scrollbarWidth}px;right:-${scrollbarWidth}px;`">
<div class="lines"> <pre class="code" v-highlightjs="version.content" contenteditable @keydown="onCodeKeyDown($event)"><code :class="[ extension ]"></code></pre>
<div class="line" v-for="line in linesCount" @click.prevent="onLineClick(line)"> <div class="lines">
<span class="added" v-if="version.addedLines.indexOf(line - 1) !== -1 && differencesActive">+</span> <div class="line" v-for="line in linesCount" @click.prevent="onLineClick(line)">
<span class="removed" v-if="version.removedLines.indexOf(line - 1) !== -1 && differencesActive">-</span> <span class="added" v-if="version.addedLines.indexOf(line - 1) !== -1 && differencesActive">+</span>
<span class="index">{{ line }}.</span> <span class="removed" v-if="version.removedLines.indexOf(line - 1) !== -1 && differencesActive">-</span>
<span class="question">?</span> <span class="index">{{ line }}.</span>
<span class="active" v-if="line === currentLine">!</span> <span class="question">?</span>
<span class="active" v-if="line === currentLine">!</span>
</div>
</div> </div>
</div> </div>
</div> </div>
+7 -1
View File
@@ -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
} }
} }
}) })