Skip to content

Commit

Permalink
feat: add updateSelectors method
Browse files Browse the repository at this point in the history
  • Loading branch information
daybrush committed Sep 11, 2022
1 parent 999c256 commit 90f40e2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/react-moveable/src/react-moveable/InitialMoveable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,23 @@ export class InitialMoveable<T = {}>
this.selectorMap = {};
this.refTargets = [];
}

/**
* If the element list corresponding to the selector among the targets is changed, it is updated.
* @method Moveable#updateSelectors
* @example
* import Moveable from "moveable";
*
* const moveable = new Moveable(document.body, {
* target: ".target",
* });
*
* moveable.updateSelectors();
*/
public updateSelectors() {
this.selectorMap = {};
this.refTargets = [];
this.forceUpdate();
}
/**
* User changes target and waits for target to change.
* @method Moveable#waitToChangeTarget
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ export default class MoveableManager<T = {}>
this.updateRect();
});
}
public updateSelectors() {}
protected unsetAbles() {
this.targetAbles.forEach(able => {
if (able.unset) {
Expand Down
1 change: 1 addition & 0 deletions packages/react-moveable/src/react-moveable/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2721,6 +2721,7 @@ export interface MoveableInterface {
setState(state: any, callback?: () => any): any;
waitToChangeTarget(): Promise<void>;
forceUpdate(callback?: () => any): any;
updateSelectors(): void;
}

export interface ControlPose {
Expand Down

0 comments on commit 90f40e2

Please sign in to comment.