Skip to content

Nodes flicker when dragging #74

Open
@rabbitfufu

Description

@rabbitfufu

One problem I have come across is that the tree 'flickers' when dragging nodes, which can be visually confusing, especially with large data sets, or when dragging multiple nested nodes.

The flicker happens because, when the placeholder is rendered, the old placeholder and the new placeholder co-exist for a split second, pushing all of the nodes in the tree down the height of the double placeholders.

In my own code that uses this component, I have fixed this problem with the following workaround...

<template>
	<Tree :data='treeData' draggable>
		<div slot-scope='{data, store}'>
			<template v-if='!data.isDragPlaceHolder'>
				...
			</template>
			<template v-else>{{killGhostPlaceholder()}}</template>
		</div>
	</Tree>
</template>

<script>
	export default {
		...
		methods: {
			killGhostPlaceholder() {
				const placeholders = this.$el.querySelectorAll('.draggable-placeholder')
				if (placeholders.length) placeholders[0].style.display = 'none'
			}
		}
	}
</script>

This quickly hides any pre-existing placeholders before a new placeholder is rendered.

It's a bit of bandage patch, but it seems to work, so maybe this will be useful...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions