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

wrong positioning #240

Open
yesilcimenahmet opened this issue Aug 27, 2020 · 8 comments
Open

wrong positioning #240

yesilcimenahmet opened this issue Aug 27, 2020 · 8 comments
Labels
question Further information is requested

Comments

@yesilcimenahmet
Copy link

Hi,

With Picker 1.6.0 there is no problem with the current settings, but when I use 1.7.2 the Picker is not positioned relative to the object. It is located in the middle of the screen.

function createColorPicker(el, opt, optForAssignToObject) {
    let options = {
        useAsButton: true,
        el: el,
        theme: 'monolith', // or 'monolith', or 'nano'
        position: 'bottom-middle',
        autoReposition: true,
        padding: 4,
        swatches: [
            'rgba(244, 67, 54, 1)',
            'rgba(233, 30, 99, 1)',
            'rgba(156, 39, 176, 1)',
            'rgba(103, 58, 183, 1)',
            'rgba(63, 81, 181, 1)',
            'rgba(33, 150, 243, 1)',
            'rgba(3, 169, 244, 1)',
            'rgba(0, 188, 212, 1)',
            'rgba(0, 150, 136, 1)',
            'rgba(76, 175, 80, 1)',
            'rgba(139, 195, 74, 1)',
            'rgba(205, 220, 57, 1)',
            'rgba(255, 235, 59, 1)',
            'rgba(255, 193, 7, 1)'
        ],

        components: {

            // Main components
            preview: true,
            opacity: true,
            hue: true,

            // Input / output Options
            interaction: {
                hex: false,
                rgba: false,
                hsla: false,
                hsva: false,
                cmyk: false,
                input: true,
                clear: false,
                save: true,
                cancel: true
            }
        },
        strings: {
            save: 'Seç',  // Default for save button
            clear: 'Temizle', // Default for clear button
            cancel: 'Vazgeç' // Default for cancel button
        }
    };
    function assignTo(dest, src) {
        if (src && typeof src == 'object') {
            for (item in src) {
                if (typeof dest[item] == 'object')
                    dest[item] = mergeRecursive(dest[item], src[item]);
                else
                    dest[item] = src[item];
            }
        }
    }
    assignTo(options, opt);
    let picker = Pickr.create(options);
    assignTo(picker, optForAssignToObject);
    picker.getPickerColor = function () {
        return this.getColor().toRGBA().toString();
    }
    return picker;
}

Environment:

Version (1.7.2):
Used bundle (normal):
Used theme (monolith): 
Browser-version:  Chrome - 84.0.4147.13
Operating-system:  Windows 10
@yesilcimenahmet yesilcimenahmet added the bug Something isn't working label Aug 27, 2020
@simonwep
Copy link
Owner

simonwep commented Sep 5, 2020

This is expected behaviour. It's one of the caveats of NanoPop that you'll normally have to handle this manually, in case of pickr it centers the popup in case there is no way of positioning it.

Anyway, could you drop me a JSFiddle example?

@simonwep simonwep added question Further information is requested and removed bug Something isn't working labels Sep 5, 2020
@yahoo0742
Copy link

yahoo0742 commented Sep 29, 2020

This seems not correct.
image

The picker is expected being above the button, rather than being clipped.
A JSFiddle example here https://jsfiddle.net/720g4ch8/1/

Thank you!

@simonwep
Copy link
Owner

simonwep commented Sep 30, 2020

@yahoo0742 Huh, you either discovered an edge-case or somethings wrong on my side, everything is as expected:
image

What is your browser / OS version? Are you using the latest pickr version?
The positioning engine pickr uses has visual tests so that must have something to do with pickr (can anyone confirm this?)

@yahoo0742
Copy link

@simonwep, thanks for your response. I tested on 3 browsers on Mac OS 10.13.6:
Chrome Version 85.0.4183.121 (Official Build) (64-bit)
Firefox 81.0 (64-bit)
And Safari Version 13.1.2 (13609.3.5.1.5)
None of them worked as yours.
An extreme case is as the screenshot below shows
image
When I click the button, the picker is completely clipped.

@simonwep
Copy link
Owner

simonwep commented Oct 2, 2020

Maybe this is related to #246? Because seeing it break on all browsers is kinda weird 🤔

@yosef-123
Copy link

how did you set this to go under the button i tried costum css and on('show') css override and always goes to middle of the page
why ?

@kirqe
Copy link

kirqe commented Jul 20, 2021

It seems the container the picker placed into should be 100vh...

Edit: The problem still exists when scrolling

ScreenFlow.mp4

@dresende
Copy link

dresende commented Jul 12, 2024

This happens on my application and from what I found, it's nanopop that does not compute a position but it's not his fault. In my case, it's document.body.getBoundingClientRect() that returns height: 0. If I manually set a height it will work properly.

In my case, to solve it, I updates my core stylesheet to have something along the lines:

html, body { height: 100% }

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

No branches or pull requests

6 participants