refactor(core): add render
This commit is contained in:
parent
aad62b65f5
commit
8bee8f0213
20 changed files with 232 additions and 102 deletions
|
|
@ -1,11 +1,19 @@
|
|||
export function eventMixin (Docsify) {
|
||||
Docsify.prototype.$bindEvents = function () {
|
||||
}
|
||||
import { isMobile } from '../util/env'
|
||||
import { dom, on } from '../util/dom'
|
||||
import * as sidebar from './sidebar'
|
||||
|
||||
export function eventMixin (Docsify) {
|
||||
Docsify.prototype.$resetEvents = function () {
|
||||
}
|
||||
}
|
||||
|
||||
export function initEvent (vm) {
|
||||
vm.$bindEvents()
|
||||
// Bind toggle button
|
||||
sidebar.btn('button.sidebar-toggle')
|
||||
// Bind sticky effect
|
||||
if (vm.config.coverpage) {
|
||||
!isMobile && on('scroll', sidebar.sticky)
|
||||
} else {
|
||||
dom.body.classList.add('sticky')
|
||||
}
|
||||
}
|
||||
|
|
|
|||
10
src/core/event/scroll.js
Normal file
10
src/core/event/scroll.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
export function activeSidebar () {
|
||||
|
||||
}
|
||||
|
||||
export function scrollIntoView () {
|
||||
|
||||
}
|
||||
|
||||
export function scroll2Top () {
|
||||
}
|
||||
28
src/core/event/sidebar.js
Normal file
28
src/core/event/sidebar.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { isMobile } from '../util/env'
|
||||
import { getNode, on, dom } from '../util/dom'
|
||||
/**
|
||||
* Toggle button
|
||||
*/
|
||||
export function btn (el) {
|
||||
const toggle = () => dom.body.classList.toggle('close')
|
||||
|
||||
el = getNode(el)
|
||||
on(el, 'click', toggle)
|
||||
|
||||
if (isMobile) {
|
||||
const sidebar = getNode('.sidebar')
|
||||
|
||||
on(sidebar, 'click', () => {
|
||||
toggle()
|
||||
setTimeout(() => activeLink(sidebar, true), 0)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export function sticky () {
|
||||
|
||||
}
|
||||
|
||||
export function activeLink () {
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue