Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nodes flicker when dragging #74

Open
rabbitfufu opened this issue May 16, 2019 · 1 comment
Open

Nodes flicker when dragging #74

rabbitfufu opened this issue May 16, 2019 · 1 comment

Comments

@rabbitfufu
Copy link

rabbitfufu commented May 16, 2019

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...

@phphe
Copy link
Owner

phphe commented May 17, 2019

thanks. I will check it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants