question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dynamic add target class not make component moveable

See original GitHub issue

Environments

Description

Have simple draft of moveable in vue. Page have 2 buttons, first button onclick add class ‘target’ to second button by vue data. I’m expect that after add class ‘target’, button should be moveable. What is wrong?

Possible after add class to element, i should call some moveable method to start work?

<div>
  <button @click="btnClick">Add target class</button>
</div>
<component
  :is="'SimpleButton'"
  :class="className"
  @mousedown="mousedown"
/>
<Moveable
  ref="moveable"
  :target="target"
  :draggable="true"
  @drag="onDrag"
/>
data() {
  return {
    target: [".target"],
    className: "test-class",
    draggable: true,
  };
},
...
btnClick(e) {
    this.className = "target";
  },

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
daybrushcommented, Sep 19, 2022

@actorius

moveable’s new version is released.

updateSelectors is missing. try again

0reactions
actoriuscommented, Sep 20, 2022

Ok, looks better. It’s should be used with nextTick, otherwise element setting moveable only on second click.

 btnClick(e) {
      this.className = "target";
      this.$nextTick(() => {
        this.$refs.moveable.updateSelectors();
      });
    },

Sandbox updated: Updated

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I target dynamic classNames? [closed] - Stack Overflow
1 Answer 1 ... It targets all elements with class attribute starting with "avatarDefault". You can also use [class*="avatarDefault"] which targets ...
Read more >
Using the HTML5 Drag and Drop API - web.dev
The HTML5 Drag and Drop API means that we can make almost any element on our page draggable. In this post we'll explain...
Read more >
Create Dynamic Target Line in Excel Bar Chart
Creating a Dynamic Target Line in Excel Bar Chart · Go to Insert –> Charts –> Clustered Column Chart · Select any of...
Read more >
Shadow DOM slots, composition
We could try to analyze the element content and dynamically copy-rearrange DOM nodes. That's possible, but if we're moving elements to shadow ...
Read more >
Dynamically Switching From One HTML Element to Another in ...
A friend once contacted me asking if I had a way to dynamically change one HTML element into another within Vue's template block....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found