mirror of
https://github.com/doocs/md.git
synced 2024-11-24 19:10:34 +08:00
feat:css move to main
This commit is contained in:
parent
26238e6241
commit
849cfb9d16
@ -1,23 +1,4 @@
|
|||||||
// 左右栏同步滚动
|
// 左右栏同步滚动
|
||||||
$(document).ready(() => {
|
$(document).ready(() => {
|
||||||
let timeout
|
|
||||||
$('div.CodeMirror-scroll, #preview').on('scroll', function callback () {
|
|
||||||
clearTimeout(timeout)
|
|
||||||
|
|
||||||
let source = $(this)
|
|
||||||
let target = $(source.is('#preview') ? 'div.CodeMirror-scroll' : '#preview')
|
|
||||||
|
|
||||||
target.off('scroll')
|
|
||||||
|
|
||||||
let source0 = source[0]
|
|
||||||
let target0 = target[0]
|
|
||||||
|
|
||||||
let percentage = source0.scrollTop / (source0.scrollHeight - source0.offsetHeight)
|
|
||||||
let height = percentage * (target0.scrollHeight - target0.offsetHeight)
|
|
||||||
target0.scrollTo(0, height)
|
|
||||||
|
|
||||||
timeout = setTimeout(() => {
|
|
||||||
target.on('scroll', callback)
|
|
||||||
}, 100)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
@ -71,7 +71,7 @@
|
|||||||
<script src="libs/scripts/prettify.min.js"></script>
|
<script src="libs/scripts/prettify.min.js"></script>
|
||||||
<script src="libs/scripts/jquery.min.js"></script>
|
<script src="libs/scripts/jquery.min.js"></script>
|
||||||
<script src="libs/scripts/closebrackets.js"></script>
|
<script src="libs/scripts/closebrackets.js"></script>
|
||||||
<script src="assets/scripts/sync-scroll.js"></script>
|
<!-- <script src="assets/scripts/sync-scroll.js"></script> -->
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
window.console
|
window.console
|
||||||
|
@ -122,12 +122,11 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import CodeMirror from 'codemirror/lib/codemirror'
|
import CodeMirror from 'codemirror/lib/codemirror'
|
||||||
import 'codemirror/lib/codemirror.css'
|
|
||||||
import 'codemirror/mode/css/css.js'
|
import 'codemirror/mode/css/css.js'
|
||||||
import 'codemirror/theme/ambiance.css'
|
|
||||||
import 'codemirror/addon/edit/matchbrackets'
|
import 'codemirror/addon/edit/matchbrackets'
|
||||||
import 'codemirror/addon/selection/active-line'
|
import 'codemirror/addon/selection/active-line'
|
||||||
import 'codemirror/addon/hint/show-hint.css'
|
|
||||||
import 'codemirror/addon/hint/show-hint.js'
|
import 'codemirror/addon/hint/show-hint.js'
|
||||||
import 'codemirror/addon/hint/css-hint.js'
|
import 'codemirror/addon/hint/css-hint.js'
|
||||||
import '../scripts/format.js'
|
import '../scripts/format.js'
|
||||||
@ -177,7 +176,8 @@ export default {
|
|||||||
form: {
|
form: {
|
||||||
rows: 1,
|
rows: 1,
|
||||||
cols: 1
|
cols: 1
|
||||||
}
|
},
|
||||||
|
timeout: null
|
||||||
}
|
}
|
||||||
d.currentFont = d.builtinFonts[0].value
|
d.currentFont = d.builtinFonts[0].value
|
||||||
d.currentSize = d.sizeOption[2].value
|
d.currentSize = d.sizeOption[2].value
|
||||||
@ -493,7 +493,34 @@ export default {
|
|||||||
duration: 1600,
|
duration: 1600,
|
||||||
type: 'success'
|
type: 'success'
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
// 左右栏同步滚动
|
||||||
|
leftAndRightScroll() {
|
||||||
|
console.log($)
|
||||||
|
$('div.CodeMirror-scroll, #preview').on('scroll', function callback () {
|
||||||
|
console.log(object)
|
||||||
|
clearTimeout(this.timeout)
|
||||||
|
|
||||||
|
let source = $(this)
|
||||||
|
let target = $(source.is('#preview') ? 'div.CodeMirror-scroll' : '#preview')
|
||||||
|
|
||||||
|
target.off('scroll')
|
||||||
|
|
||||||
|
let source0 = source[0]
|
||||||
|
let target0 = target[0]
|
||||||
|
|
||||||
|
let percentage = source0.scrollTop / (source0.scrollHeight - source0.offsetHeight)
|
||||||
|
let height = percentage * (target0.scrollHeight - target0.offsetHeight)
|
||||||
|
target0.scrollTo(0, height)
|
||||||
|
|
||||||
|
this.timeout = setTimeout(() => {
|
||||||
|
target.on('scroll', callback)
|
||||||
|
}, 100)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
this.leftAndRightScroll()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -5,7 +5,9 @@ import store from './store'
|
|||||||
import ElementUI from 'element-ui'
|
import ElementUI from 'element-ui'
|
||||||
import 'element-ui/lib/theme-chalk/index.css'
|
import 'element-ui/lib/theme-chalk/index.css'
|
||||||
import './element'
|
import './element'
|
||||||
|
import 'codemirror/lib/codemirror.css';
|
||||||
|
import "codemirror/theme/ambiance.css";
|
||||||
|
import "codemirror/addon/hint/show-hint.css";
|
||||||
Vue.use(ElementUI)
|
Vue.use(ElementUI)
|
||||||
|
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
|
Loading…
Reference in New Issue
Block a user