Cypress scroll till the end - dynamic

There is the scrollIntoView and the scrollTo. Both of them scroll only for a specific duration of time. E.g. the cy.scrollTo(100, 100) won't scroll at all, because the default duration is 0 and the cy.scrollTo(10000, 10000, { duration: 1000 }) won't actually scroll ten thousand pixels, but only as many pixels as it will be able to scroll in 1000 milliseconds.
So, I would have to put a big duration value and hope for the scroll to complete. And my question is: Is it possible in Cypress to scroll the specific number of pixels irrespectively of how much time it will take?
I.e. I need the cy.scrollTo(100, 100) to actually scroll 100 pixels and the cy.scrollTo(10000, 10000, { duration: 1000 }) to also scroll the actual 10000 pixels. The size of my containers may change (due to the variable contained data), so it makes zero sense for me to try to guess the number I need to put in the duration.

Adding the wait(0) after the scrollTo(100, 100) did the trick. I.e. : scrollTo(100, 100).wait(0).

Related

how to add slider in tool mode?

I'm trying to add a slider in tool mode like this:
code:
tool
extends Position2D
export(float) var CustomSlider = 0.1 setget changeSlider_x
func changeSlider_x(changed_val):
CustomSlider=changed_val
First of all, I want to point out that this variable:
export(float) var CustomSlider = 0.1
Is a variant. Even thought Godot shows it as a float on the inspector panel.
This is a float and Godot will also show it as float in the inspector panel:
export var CustomSlider := 0.1
Or if you prefer the type to be explicit, you can write it like this:
export var CustomSlider:float = 0.1
What you specify between parenthesis after export is to controls how it will be shown in the inspector panel.
I know the documentation is a little hard to find - because there are other things called "export" - but here it is: GDScript exports
Now, to get a (useful) slider, you have to either:
Specify a range of values:
export(float, 0, 10) var CustomSlider:
Specify a range of values, with snapping to a step size:
export(float, 0, 10, 0.1) var CustomSlider:
The snapping will be to a multiple of the step size. That is, the snapping is not offset by the minimum and maximum.
Specify an exponential slider, with a maximum greater than zero (the minimum will be zero):
export(float, EXP, 10) var CustomSlider:
With this the slider is not linear. You will find that at the half point the value is the square root of the maximum, not the half. And a third of the way, you find the cubic root of the maximum, and so on. As a result, number are more tightly packed near the maximum (e.g. for a range from 0 to 100, the half point is 10, so the first half goes from 0 to 10 and the second half goes from 10 to 100).
Specify an exponential slider, with a minimum and a maximum:
export(float, EXP, 10, 100) var CustomSlider:
This is similar to the behavior above, except it is offset so the minimum is not zero, but the one you specified.
Specify an exponential slider, with a minimum, a maximum, and snapping to a step size:
export(float, EXP, 10, 100, 2) var CustomSlider:
This creates an exponential slider similar to the previous case. Except this one will snap the value, similar to the snapping described before.
Aside from using export, there is another way to have something show in the inspector panel: use _get_property_list (requires a tool script), which would give us more control (some options are only available this way). Furthermore, we could call property_list_changed_notify to tell Godot to check again what it should show in the inspector panel, and that would allow you to have it change dynamically.
By the way, you can write your variable name in lower caps and with _, and Godot will capitalize it and replace the _ with spaces when it shows it in the inspector panel.

VueJS - Flexed columns / fitting table to any width of the screen in ag-grid-vue

I am using Ag-grid in order to display table, i am looking to make my table responsive.
So i am trying to fit the whole table/ whole columns to what ever the width of the screen is:
If the width of the screen is less than 500px only then i want to make the the x-axis scrollable, otherwise the entire table/ entire columns should fit the screen.
Here is the codesandbox:
https://codesandbox.io/s/priceless-khorana-bw55b
Initially the table was leaving space like this:
I also tried this in mounted:
mounted () {
this.gridApi = this.gridOptions.api.sizeColumnsToFit()
}
I get below image when i reduce the width of the screen and when i have used sizeColumnsToFit():
But the sizeColumnsToFit() works fine when the width of the screen is full.
I also referred the documentation of ag-grid, and found out the below link:
https://plnkr.co/edit/YG7be1X8kAgeSEas, this is what i am looking for, and i also tried the same as example but don't know why i could not make my table responsive like that.
So, please help me in making my table fit to what ever the width of the screen is. As the width keeps decreasing and if its less than 500px only then i want to make it scrollable. Then, i also want to reduce the space between columns, so it becomes easy to fit the table.
Use the grid event gridSizeChanged to call a function each time your grid size changes. In this function, call sizeColumnsToFit to auto size your columns if your grid size is more than 500px, else, resize each of the columns to a more reasonable width each, e.g. 300px;
onGridSizeChanged(params) {
if (params.clientWidth > 500) {
this.gridApi.sizeColumnsToFit();
} else {
this.columnDefs.forEach(x => {
x.width = 300;
});
this.gridApi.setColumnDefs(this.columnDefs);
}
},
Demo.
In order to reduce the space between the columns, use defaultColDef to remove the padding from the cells, and set the padding to 0 for the ag-header-cell class for the headers
Demo.

ngx-charts-bar-vertical-2d minimum bar width

I would like to set the width of the bars to be a minimum of 12px. I would actually prefer to have a fixed width on the bars period.
As an example, when I am displaying 10 days of data, the graph looks fine, but for 30 days, it does not look good at all. Any thoughts on making this look better?
I added a horizontal scroll, but the width of the bars is automatically calculated based on the number of items in the graph, irrespective of the graph width. Is there any way to alter this behavior?
Screen capture: https://share.getcloudapp.com/yAubDN8X
Try adding [barPadding]="1" to ngx-charts-bar-vertical-2d element
<ngx-charts-bar-vertical-2d [barPadding]="1" ...>...</ngx-charts-bar-vertical-2d>
Try adding [groupPadding]="1" to ngx-charts-bar-vertical-2d element
<ngx-charts-bar-vertical-2d [groupPadding]="1" ...>...</ngx-charts-bar-vertical-2d>
as long as you minimize the padding between groups, the barWidth with grow automatically !

How to optimize: add/subtract a value until it is within a predefined range?

I have a value range, say the iPhone screen size 480x320. I have a position that may be outside the range, let's say the position's x coordinate is 600 for example.
In order to adjust the x coordinate to its on-screen position I can do: 600 - 480 = 120
But when the value is greater than two times 480 I'd have to run a loop, subtract 480 until the resulting number is below 480.
I know there's an optimization to this problem revolving around division/modulo but I just can't find a good answer (or question) related to this. Mainly because I can only guess possibly helpful search phrases.
I'm feeling sick today and for the live of me I can't wrap my head around it. I'd welcome any pointers, even a "close as duplicate".
PS: this is for Objective-C but any language will do.
You are looking for the modulo operator. The solution for the case of a width of 480 is:
x % 480
Modulo will guarantee that the resulting value is between 0 and 479.

Objective C: Change Line Width Using UISlider

I have this code to change the stroke width of the line i'm using to draw on the screen.
- (IBAction)changeSize:(id)sender
{
if (Slider.value > 25.0)
{
Width += 3;
}
}
It's working but when i drag the slider thumb straight to the maximum it just adds a little size only but when i do it partly it's getting bigger each step.
Also, when i decrease it on the UISlider it still adds more... it's not decreasing...
How can i do resizing using UISlider??
It looks like you are telling it to increase the width by 3 when the slider is changed.
You would need to set the width equal to the slider value.
Well, you need to understand how sliders work. The Slider.value is your current slider value and it goes from Slider.minimumValue to Slider.maximumValue, witch you can set when creating the slider. You should set those to your minimum line stroke and to maximum line stroke.
In your changeSize method you should then only have 1 line: Width = Slider.value; What you are doing now, is that each time you move the slider and its value is larger then 25.0, you increase the stroke by 3.
As for the speed of slider movement effecting the stroke in your case: How many times the method changeSize will be called is time based, not value. So if you slide it faster, it will be called lesser times then if you slide it slowly, therefor increasing your Width lesser times by 3.