[QUESTIONS] resizable, using unitWidth in px output into percent.
See original GitHub issueHi @artf,
Thanks for making this amazing framework. Recently I made a custom component based on your flexbox plugin.
The red arrow is the actual value of the model. The green arrow is what I expected to be.
Is that possible to set unitWidth
as px
but the output to be percent
?
Here is what I’ve tried
- I separated them as 2 component,
grid
component, only as a container that will then I set the display intoflex
,column
component, which I put the resizable.
- set resizable
const keyWidth = 'width'
const step = 1
const minDim = 1
const unitWidth = 'px'
const resizerRight = {
...resizerBtm,
tl: 0,
tc: 0,
tr: 0,
cl: 0,
cr: 1,
bl: 0,
bc: 0,
br: 0,
keyWidth,
currentUnit,
minDim,
step
unitWidth
}
- Makes the
column
listen to the resizing event. (I am not sure if this was correct, I might need to make a new different post for this question)
init () {
this.listenTo(this, 'change:style ', this.updateWidth)
//...
}
- I want to update the model width from pixel into percent using simple math.
updateWidth(model) {
//...
model.setStyle({
width: parseFloat(selectedWidth, 10) / containerWidth * 100 + '%'
})
//...
}
I am aware that the code above would create an infinite resizing. So, I am looking for another solution which leads me to the resizable source code.
I am wondering if I could make use of the methods listed there
var defaultOpts = {
// ...
mousePosFetcher: null,
// Indicates custom target updating strategy
updateTarget: null,
// Function which gets HTMLElement as an arg and returns it relative position
ratioDefault: 0,
posFetcher: null,
onStart: null,
onMove: null,
onEnd: null,
// ...
}
here is the demo link and the code
Sorry for this long post, I just want to make it easier for you to understand my case.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How to change correctly font-size:x% with pt or px?
The code from here seems to be close to what you need, specifically: switch (unitSize.Unit.Type) { case UnitType.Pixel: result = (int)Math.Round(unitSize.
Read more >Solved: Resizing layers using pixels instead of percentage...
Right now the info panel shows only percentages. I would like to know the current pixel size, height and width, so I know...
Read more >Resize and position items using percents or pixels
Resize and position items using percents or pixels. You can resize layout items (images, overlay text, and multiple video sources) using the percent/pixel...
Read more ><percentage> - CSS: Cascading Style Sheets - MDN Web Docs
Numerous properties can use percentages, such as width, height, ... a real value (such as a width in pixels for a <length> value)...
Read more >How to resize image with percent in powertoys - Super User
I am using the image resizer tool in powertoys to resize multiple images at once. The problem is when I switch the unit...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You are the man!!! 👍 👍 Thank you so much @artf.
Ah wait, my fault,
opts
is the 3rd oneupdateWidth(model, value, opts = {}) {
btw the second argument in setStyle are options (eg,{ silent: true }
to avoid triggering change listeners) and you get those options also in the callback of your listeners so I just placed a custom keyfromPxToPerc
to know when the change is triggered from your custom logic