optmization

This commit is contained in:
jiaming743 2020-06-10 09:45:21 +08:00
parent ea058a90c3
commit 1d0f369509
1 changed files with 22 additions and 21 deletions

View File

@ -37,9 +37,9 @@
:style="`width: ${widths[ci]}px;`" :style="`width: ${widths[ci]}px;`"
:align="aligns[ci]" :align="aligns[ci]"
v-html="ceil" v-html="ceil"
@click="emitEvent(ri, ci, row, ceil)" @click="emitEvent('click', ri, ci, row, ceil)"
@mouseenter="changeHover(true,ri, ci, row, ceil)" @mouseenter="handleHover(true, ri, ci, row, ceil)"
@mouseleave="changeHover(false)" @mouseleave="handleHover(false)"
/> />
</div> </div>
@ -148,7 +148,14 @@ export default {
* @default carousel = 'single' * @default carousel = 'single'
* @example carousel = 'single' | 'page' * @example carousel = 'single' | 'page'
*/ */
carousel: 'single' carousel: 'single',
/**
* @description Pause scroll when mouse hovered
* @type {Boolean}
* @default hoverPause = true
* @example hoverPause = true | false
*/
hoverPause: true
}, },
mergedConfig: null, mergedConfig: null,
@ -184,22 +191,16 @@ export default {
} }
}, },
methods: { methods: {
changeHover(flag,ri, ci, row, ceil){ handleHover(enter, ri, ci, row, ceil){
if(flag){ const { mergedConfig, emitEvent, stopAnimation, animation } = this
if(this.config.hoverPause){
this.stopAnimation(); if (enter) emitEvent('mouseover', ri, ci, row, ceil)
} if (!mergedConfig.hoverPause) return
const { ceils, rowIndex } = row
this.$emit('mouseover',{ if (enter) {
row: ceils, stopAnimation()
ceil,
rowIndex,
columnIndex: ci
})
} else { } else {
if(this.config.hoverPause){ animation(true)
this.animation(true)
}
} }
}, },
afterAutoResizeMixinInit () { afterAutoResizeMixinInit () {
@ -375,10 +376,10 @@ export default {
clearTimeout(animationHandler) clearTimeout(animationHandler)
}, },
emitEvent (ri, ci, row, ceil) { emitEvent (type, ri, ci, row, ceil) {
const { ceils, rowIndex } = row const { ceils, rowIndex } = row
this.$emit('click', { this.$emit(type, {
row: ceils, row: ceils,
ceil, ceil,
rowIndex, rowIndex,