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

Dragging items do not position on intital drag? #2824

Closed
tonypartridge opened this issue Jun 11, 2020 · 6 comments
Closed

Dragging items do not position on intital drag? #2824

tonypartridge opened this issue Jun 11, 2020 · 6 comments

Comments

@tonypartridge
Copy link

So when I drag a component/item from the bar to the center it will not go where I told it to go... IT always goes about 20% page width to one side? Once added it's adjustable. See this gif:
https://gyazo.com/87076de55a1853e80b5dd7ea14ccb94e

Does anyone have any suggestions?

@RJCAM
Copy link

RJCAM commented Jun 11, 2020

Hi @tonypartridge
Do you have the last GrapesJS version?
This is working fine for me with the dragMode: "absolute",
Check this basic code below:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>GrapesJS</title>
    <link href="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet">
    <script src="https://unpkg.com/grapesjs"></script>
    <style>
        body,
        html {
            height: 100%;
            margin: 0;
        }
    </style>
</head>

<body>

    <div id="gjs" style="height:0px; overflow:hidden"></div>

    <script type="text/javascript">
        var editor = grapesjs.init({
            height: '100%',
            dragMode: "absolute",
            noticeOnUnload: 0,
            storageManager: {
                autoload: 0
            },
            container: '#gjs',
            fromElement: true,
            plugins: [],
            pluginsOpts: {}
        });

        editor.BlockManager.add('test-block', {
            label: 'Div',
            attributes: {
                class: 'gjs-fonts gjs-f-b1',
            },
            content: `<div class="test">This is a simple div</div>
            <style>
                .test {
                    width: 200px;
                    height: 30px;
                    text-align: center;
                    background-color: lightgrey;
                }
            </style>`,
        });
    </script>
</body>

</html>

@artf
Copy link
Member

artf commented Jun 17, 2020

yeah... I can actually reproduce the same issue when a smaller device view is enabled, probably some kind of regression. I need time to investigate but at the moment I'm kind of busy with other stuff and dragMode is not my priority right now. So, I hope someone else could look at this

@soltanloo
Copy link

soltanloo commented Sep 4, 2020

I have the same issue when I'm using the absolute drag mode. Blocks always fall out of the canvas and I need to scroll to grab them and place them back into the original desired position.
@tonypartridge Did you figure out any way to fix this?

@tonypartridge
Copy link
Author

tonypartridge commented Oct 12, 2021

@soltanloo not yet, how about you? @artf did you have any luck?

@artf
Copy link
Member

artf commented Oct 16, 2021

@tonypartridge not yet but I close this issue as I'm planning to solve all ones related to absolute positioning here: #3770

@artf artf closed this as completed Oct 16, 2021
@tonypartridge
Copy link
Author

Ok thank you @artf!

contentfree added a commit to contentfree/grapesjs that referenced this issue Jun 15, 2022
artf added a commit that referenced this issue Jun 18, 2022
…vas. (#4387)

Take canvas offsets into account when dropping a new block on the canvas. Relates to #2824

Co-authored-by: Artur Arseniev <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants