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

Disabling Auto-Fit? #41

Closed
evolross opened this issue Oct 25, 2018 · 6 comments
Closed

Disabling Auto-Fit? #41

evolross opened this issue Oct 25, 2018 · 6 comments

Comments

@evolross
Copy link

evolross commented Oct 25, 2018

Is there any way to disable the way the color-picker "auto fits" to the visible screen area?

This is happening in my app and the color picker gets moved to an area that covers up my UI and leaves the user unable to click the necessary buttons to choose a color or close the color picker.

Could I add a PR to pass this as a setting parameter when initiating? Or would this be something easy you could do?

EDIT: I see there's a fit hook that gets called when the color picker gets auto fitted, but there doesn't seem to be any easy way to "undo" or cancel the auto fit using that hook.

@evolross
Copy link
Author

That broke the placement altogether. I can't see the color picker at all now. This is probably wiping out its location entirely no?

@taufik-nurrohman
Copy link
Owner

taufik-nurrohman commented Oct 26, 2018

Or just set some fixed offsets:

var left = e.target.offsetLeft,
    top = e.target.offsetTop;

picker.fit([left, top]);

@evolross
Copy link
Author

evolross commented Nov 2, 2018

I tried calling this inside of picker.on("enter", function(picker) {...} which works now (thank you) but there's nothing passed to the listener. So picker.self.offsetLeft is undefined.

If I try putting the above code into the picker.on("fit", function(picker) {...} listener, I can do that, but when I call picker.fit([left, top]) it creates an infinite loop, logically.

Where/when were you thinking the above code would live?

@taufik-nurrohman
Copy link
Owner

You can now use this.self.offsetLeft within the scope.

@evolross
Copy link
Author

Circling back to this. I figured it out. Your very first suggestion/example was correct. I wasn't setting a placement element as the third param to the constructor. That's why overriding picker.fit wasn't working. Once I set a placement element, I could dial in the location perfectly using:

picker.fit = function() {
   //  Don't autofit picker - always set static location
   this.self.style.top = "34px";
   this.self.style.left = "37px"; 
};

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

No branches or pull requests

2 participants