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

Hiddentextarea auto scroll the page #2904

Closed
keanass opened this issue Apr 25, 2016 · 13 comments · Fixed by #3057
Closed

Hiddentextarea auto scroll the page #2904

keanass opened this issue Apr 25, 2016 · 13 comments · Fixed by #3057

Comments

@keanass
Copy link

keanass commented Apr 25, 2016

Hiddentextarea is scrolling the webpage when double click it to modify the text content in latest version of fabric, it maded for ios to show the keyboard but that takes effect also in computer browsers.

@keanass
Copy link
Author

keanass commented Apr 25, 2016

i think you must keep it like that with position fixed and do not focus it :

<textarea autocapitalize="off" style="position: fixed; bottom: 20px; left: 0px; opacity: 0; width: 0px; height: 0px; z-index: -999;"></textarea>

@asturur
Copy link
Member

asturur commented Apr 25, 2016

HiddenTextarea must move around the itext object to serve composition purposes.
If it is not focused, most of the events do not fire.
What is the problem of the page scrolling on textbox when editing? Can you share a particular setup where this hurts?

@keanass
Copy link
Author

keanass commented Apr 29, 2016

this.initHiddenTextarea(e);
this.hiddenTextarea.focus();

if the canvas size is big and double click on a textbox to edit it it, the whole page is getting scrolled to position of this textbox.

@asturur
Copy link
Member

asturur commented Apr 29, 2016

please make a demo on 1.6.1
On Apr 29, 2016 12:14 PM, "keanass" [email protected] wrote:

this.initHiddenTextarea(e);
this.hiddenTextarea.focus();

if the canvas size is big and double click on a textbox to edit it it, the
whole page is getting scrolled to position of this textbox.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#2904 (comment)

@netray
Copy link

netray commented May 2, 2016

I believe I have the same issue.

This is the demo:
https://jsfiddle.net/m9bweyc4/2/

Usecase:
FullHD canvas element is inserted into a smaller wrapper and scaled using CSS to fit that container / screen, thanks to this the end result is always full hd, events are scaled nicely using .getPointer method.
The only thing that ignores scaling is the hidden textarea that takes the coordinates from the canvas itself and causes the whole page to scroll.

Hope it helps.

@asturur
Copy link
Member

asturur commented May 2, 2016

I will see if with the logic of getPointer we can also move the textArea better.
But that this css scaling is not a good idea in my opinion. You pay the performace load of a full size but work in small size, while you could work in small size and get the bigone when going to dataURL({multiplier: 10});

@keanass can you please also make a demo to check if the issue is the same?

@danivallucas
Copy link

The webpage scrolls also in a canvas with zoom < 1 (Chrome).

Add a 600x400 canvas.
Then set canvas zoom to 0.5 and add an IText at left=800 and top=700, for example, so it will be next the right bottom corner.
When enter editing the page will scroll because fabric will try to manipulate hiddenTextArea at point (1600, 1400) I guess.
My screen resolution is 1366x768.

Workaround: I changed initHiddenTextarea and _updateTextarea considering zoom at "p" point:

        p.x *= canvas.getZoom();
        p.y *= canvas.getZoom();

@raffareis
Copy link

this is really annoying, had to solve this by setting p.x=0 on initHiddenTextarea and _updateTextarea.

@stephenmudra
Copy link

I'm seeing a similar issue, can be seen on http:https://fabricjs.com/kitchensink as well.

If you add a long enough single text line it pushes the page over when it reaches the browser window.
In my use case as I was centring the canvas the issue was visible as soon as the textarea left the canvas boundaries.

The work around I added was preventing the textarea from positioning itself outside of the canvas, which seemed to work for my use case. However I'm not using zoom or css resizing.

@asturur
Copy link
Member

asturur commented May 16, 2016

for sure canvas zooming is something to solve. for the css i do not know if i can help somehow. Maybe we should have a paramerer to have it fixed(no mobile support) and repositioning (issues with big pages and css)

@jfbloom22
Copy link

Adding this css worked well for me:
textarea[data-fabric-hiddentextarea]{ position: fixed !important; }

opinion: Unless the project is built entirely on fabricjs, then a lot of projects will already have a solution inlace to zoom to the input or create space for the on screen keyboard. Thus, it seems to me this feature should either not be a part of fabricjs, or there should be an easy option to disable it. In my use case, disabling this feature worked better on iOS and the desktop browser.

@asturur
Copy link
Member

asturur commented Sep 27, 2017

i added a special attribute to the textarea to allow people to interact with it in some way.
Not sure if it helps

@vimlesh1975
Copy link

Adding this css worked well for me: textarea[data-fabric-hiddentextarea]{ position: fixed !important; }
I faced this issue and @jfbloom22 solution worked.

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

Successfully merging a pull request may close this issue.

8 participants