refactor(core): add render

This commit is contained in:
qingwei.li 2017-02-17 23:09:09 +08:00 • committed by cinwell.li
commit 8bee8f0213
20 changed files with 232 additions and 102 deletions

View file

@ -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
View file

@ -0,0 +1,10 @@
export function activeSidebar () {
}
export function scrollIntoView () {
}
export function scroll2Top () {
}

28
src/core/event/sidebar.js Normal file
View 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 () {
}