Conversation
… size and container size.
…size calculations.
Do you think there is way to make one single |
|
I thought about it: The math part could easily be shared. But since this is client related code, and clients are different (mobile-web), it might be a good idea to let those calculations be updated separately. So, for example, if the way these sizes are calculated had to change on the web side for any reason, it doesn't affect mobile. If that's true, we are not repeating code, but the fact that they look like the same is a temporal coincidence. Anyway, we can decide to share the code if we are sure it will be always the same for all the platforms. If that's the case, I'd agree on doing it on a future PR. 👍 |
|
Can we extract the computation code to its own function and in a dedicated module? The idea here is to then have a |
…n web and mobile.
|
Thanks @hypest ! I made the change we talked about: The mobile version is working as before, and the web tests are all passing (locally at least). |
There was a problem hiding this comment.
👋 @etoledom ! I only left one minor comment but, in general I think the implementation of ImageSize and utils.js is in the right direction but still feels kinda awkward. Perhaps having the util functions become a class that ImageSize can then extend could help clarify the code? I'm not too sure about it though and I think I could use a GB web dev's opinion here so, I'll leave that for others to review.
| */ | ||
| import { noop } from 'lodash'; | ||
|
|
||
| import { Component } from '@wordpress/element'; |
There was a problem hiding this comment.
Let's reinstate the WordPress dependencies section header here.
|
@hypest - Maybe implementing that in the way @daniloercoli suggested would be less invasive? |
Hmm, not sure what exactly is different right now, compared to Danilo's sugegstion. Perhaps I didn't understand Danilo's suggestion. In any case, the code doesn't seem to be too invasive. It's OK to refactor web-side code to help group the platform agnostic code from the platform specific so, as far as I can tell, we're good so far. I still think that we could use an eye from a web side colleague so, let's wait. @gziolo , maybe you can have a look here? There's a chance my "... is the right direction but still feels kinda awkward" comment needs some explaining. I was looking at the code and noticed this pattern: onLayout( event ) {
onLayout( event, ( container ) => {
this.container = container;
this.calculateSize();
} );
}Now, it seems that in |
|
@hypest - @daniloercoli idea was (and please correct me if I'm wrong) actually the opposite: We would keep the I believe that, in this way, the implementation of the shared code would be simpler and less invasive on the web part, but reduced to just a couple of functions. You are right, I believe that, in the case of I'll push an update with this change. |
…/image-block-vol-03
|
This PR was replaced by #13096 |
Description
This PR adds the ability to the image block of interpreting size changes made by the user.
I added a temporal size setting UI for testing purposes, but this should be replaced later with the definitive block settings UI.
I keep following closely the logic used on the web version, so (hopefully) anybody can later on check it out and understand it easily.
The visual resizing of the image currently doesn't behave exactly as on the web version, but this PR is intended to add the basics of resizing. Layer on we can decide how do we want this to behave exactly on mobile.
This is not supposed to handle image updates (change of images) either.
Screenshots
To test: