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

.moveable-control-box placed on incorrect position #711

Closed
seahindeniz opened this issue Aug 3, 2022 · 3 comments
Closed

.moveable-control-box placed on incorrect position #711

seahindeniz opened this issue Aug 3, 2022 · 3 comments
Labels
bug Something isn't working complete
Milestone

Comments

@seahindeniz
Copy link

seahindeniz commented Aug 3, 2022

Environments

  • Framework name: Vanilla
  • Framework version: -
  • Moveable Component version: 0.34.2
  • Testable Address(optional): added blow

Description

When I create a moveable instance, the control box container position gets calculated incorrectly.
Here's a demo video

Sample 1 - https://www.marionnaud.at/

Screen.Recording.2022-08-03.at.10.26.32.mp4

Sample 2 - https://www.iciparisxl.nl/

Screen.Recording.2022-08-03.at.11.38.11.mp4

For this case, the reproduce example is going to be a Tampermonkey user script file. I couldn't able to identify the source of the problem because from what I can see, the getBoundingClientRect returns the correct output. But the main issue is happening on the navigation bar of the sample websites.

New Userscript.user.js
// ==UserScript==
// @name         Moveable position issue
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  MRE - Minimal reproducible example
// @author       You
// @match        https://www.marionnaud.at/*
// @match        https://www.iciparisxl.nl/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=marionnaud.at
// @grant        none
// @require      https://cdnjs.cloudflare.com/ajax/libs/moveable/0.34.2/moveable.min.js
// @run-at       document-idle
// ==/UserScript==


(() => {
    // Prevent other interractions to select an element
    ['click', 'mouseover', 'mouseenter', 'mouseleave'].forEach(name => {
        window.addEventListener(name, event => {
            event.stopPropagation();
            event.preventDefault();
        }, true);
    });

    let moveableInstance;

    window.addEventListener('click', event => {
        moveableInstance?.destroy();

        moveableInstance = new Moveable(document.body, {
            target: event.target,
            edge: true,
            keepRatio: false,
            origin: false,
            renderDirections: ['n', 'nw', 'ne', 's', 'se', 'sw', 'e', 'w'],
            resizable: true,
            zoom: 0.645,
            preventClickDefault: true,
        });
    }, true);
})();
@seahindeniz
Copy link
Author

seahindeniz commented Aug 3, 2022

I think I have identified the root cause. The element that I was targeting, their parent elements have will-change: transform; property and disabling it from the Chrome DevTools, did worked.

But there is another issue lays off, is there a way to implement a solution without removing the will-change property?
Like, clicking on an element and searching for will-change property by executing window.getComputedStyle method on parent elements recursively, will be a costly solution, speaking from the performance perspective

@daybrush daybrush added the bug Something isn't working label Aug 3, 2022
@daybrush daybrush added this to the 0.35.0 milestone Aug 3, 2022
@daybrush
Copy link
Owner

daybrush commented Aug 3, 2022

@seahindeniz

moveable's new version is released. Check it again.

@seahindeniz
Copy link
Author

It is working as expected 👏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working complete
Projects
None yet
Development

No branches or pull requests

2 participants