diff --git a/src/directive/directive.js b/src/directive/directive.js index e57ad0b701c67b533be50cf62fd57124fc7d6a04..26e22d192d0a36b942bca790933001e3d944297f 100644 --- a/src/directive/directive.js +++ b/src/directive/directive.js @@ -22,4 +22,41 @@ let validator = { } } -export { validator } \ No newline at end of file + +function loading(value) { + let type = typeof value + if (type !== 'boolean') { + console.error(new Error(`Expected a Boolean value but got one ${type}`)) + } + let canvasId = document.getElementById('canvas-box') + if (!!value) { + canvasId.style.display = 'block' + } else { + canvasId.style.display = 'none' + } +} + +let waiting = { + inserted: function(el, binding) { + loading(binding.value.value) + let waitingText = document.getElementById('waiting-text') + binding.value.text && (waitingText.innerText = binding.value.text) + /* + * 参数详解: + * upTime 上移的时间 + * downTime 下落的时间 + * beatHeight 上移高度 + * isAuth 是否自动 + * isRotate 是否旋转 + */ + window.$(waitingText).beatText({ isAuth: true, beatHeight: '1em', isRotate: false, upTime: 100, downTime: 100 }) + }, + update: function(el, binding) { + loading(binding.value.value) + let waitingText = document.getElementById('waiting-text') + binding.value.text && (waitingText.innerText = binding.value.text) + window.$(waitingText).beatText({ isAuth: true, beatHeight: '1em', isRotate: false, upTime: 100, downTime: 100 }) + } +} + +export { validator, waiting } \ No newline at end of file