-
Notifications
You must be signed in to change notification settings - Fork 6
Fixed image resize flashing unexpected size #112
Conversation
… the resize handle.
…ance. This will cause fewer API changes than adding editor / writer instance to required functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
src/widgetresize/resizer.js
Outdated
* @private | ||
* @type {module:engine/view/element~Element|null} | ||
*/ | ||
this._resizerWrapperView = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "view" doesn't mean that it's a view but it comes from the view so it's an adjective and should be the first word. Just like in the variable which you actually use below:
this._resizerWrapperView = viewResizerWrapper;
Next to the viewResizerWrapper
you have a domResizerWrapper
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also fix the description of this property.
Yup, that's a minor. |
Co-Authored-By: Piotrek Koszuliński <pkoszulinski@gmail.com>
…roperty. Also linting: fixed line that violated 140 chars policy. This line skipped linter as it was commit straight from GH web interface. MINOR BREAKING CHANGE: Removed downcastWriter property from the ResizerOptions interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IDK which bottleneck we're hitting right now, but I found a followup which may be worth checking if we identify the issue to be in mutation observer: ckeditor/ckeditor5#5600.
We just had a discussion with @Reinmar about this issue. Here are following actions:
More details: The performance hit comes from the fact that now as the code use CKE5 views for DOM manipulation (does not do changes in the DOM directly), there are two On a side note there's also slightly related problem, where changes in our size UI are causing extra mutations. That's tracked in ckeditor/ckeditor5#5600. |
This PR is blocked by ckeditor/ckeditor5#5964 as it needs to utilize |
I tested the new disable/enable API as mentioned in #113. I think you can update this PR now. |
…that it doesn't fail if it isn't included in the editor.
Now resizer hides widget toolbar during the resize. I made a soft check on Also the actual toolbar hide logic was hooked to Resizer's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you click on the resize handle, the toolbar disappears and it never reappears, even if you select another widget.
…zer with no dragging. See ckeditor/ckeditor5-widget#112 (review).
Toolbar works fine now. There is a strange issue with resizing an image that is in |
☝️ same in Safari, however, I didn't notice weird behaviour after releasing the mouse button. Besides this small issue, it looks good. |
Yeah, the logic for handling an image without a width is tricky and can manifest like that. We had to take some shortcuts there – basically, we estimate the real width. Thanks for checking this PR. I'm merging it. |
Suggested merge commit message (convention)
Fix: Fixed image resize behavior upon short clicking a handle without dragging. Image will no longer became full width, nor will it briefly flash an unexpected size. Closes ckeditor/ckeditor5#5189 and closes ckeditor/ckeditor5#5195.
MINOR BREAKING CHANGE: Resizer options object now also takes an editor instance.
Additional information
downcastWriter
so I'd also like to remove this property. I find it to be a minor breaking change, please confirm that.Short overview of the problems:
flickering image at the first render (#5189)
The issue is caused by the fact that we played a little against the UI with the initial implementation.
The resizer was applying the new
width
styles directly to theimg
DOM element, skipping view abstraction. What happened there was that imageresize plugin added aimg.image_resized
class to theimg
's view, which gives it a100%
width. Since the view knew nothing about the width attribute, it did not add it while re-renderingimg
. Thus was getting full width for a brief moment, until the DOM img was modified once again directly.Now implementation works with view, that required me to pass
editor
instance to the resizer so I can request for a view writer.committing full image width, when end user only clicks the handle (but does not move the cursor) (#5195)
The problem is caused by the fact that
commit()
accesses an uninitialized state. And this occurs when user clicks the resize and releases the cursor but does not triggermousemove
event, thus the state is never initialized.It could be worked around in the imageresize plugin itself (just checking the state here), but the fix should be in the core and prevent commit from being issued.
Subprs: