I have a scrollrect object on a UI canvas that has a viewport object child, and the viewport object has a content object child that stores all of the items to be scrolled.
I have selected the viewport for reference. I want to resize the viewport rect relative to LevelScroller (see hierarchy) in order for there to be a margin around the scrollview, so that the scrolling items do not touch the edge of the gray LevelScroller rect. But the viewport rect is not resizeable. Right now the result is this:
See how the button at the top (1S-Levitation) is cut off by the grey panel. I want there to be a margin between the point where it is cut off and the gray box.
I have tried adding a horizontal layout group to LevelScroller to forcibly add a margin, but this did not work. Why is the viewport not resizeable?
Any help is appreciated
I believe that the viewport is not resizable because it is supposed to manage how your scroll will behave during the user interaction. As an example, you have only one cell in your content container and the user drag it down, once it is released it is supposed to move back to the top of your viewport, and if you put a margin in there it will not be capable of move entirely back to the top.
But hopefully you can do the following trick to have your margin:
Create an empty game object called Scroller and set it as the father of your LevelScroller. Then, set your LevelScroller RectTransform to stretch in both directions, and set the desired margin on the RectTransform Top, Bottom, Right and Left fields. You should have something like this:
LevelScroller as a child with 10 pixels of top and bottom margin
Then create another empty object child of your parent Scroller, and put it behind the LevelScroller. Lets call it BgImage. Now, set the RectTransform of BgImage to stretch in both directions and add an image to it. Ta daaa, you should have now your background with your margins on your viewport.
BgImage working as the background of the LevelScroller
Related
I have a borderPane with a menu top,a grid left and an image in the center.I want the image to have the same size as the center of the border because now the image goes over my grid.
I tried this:
imageView.fitWidthProperty().bind(box.widthProperty());
where imageView is the name for my image and box is the BorderPane object.Thank you.
See JavaFX Feature Request RT-21337 Add ImageViewPane and MediaViewPane controls which contains a code attachment for a sample ImageViewPane implementation which which will resize the ImageView it contains to the area available to the region. To get the behaviour required you might also need to implement computeMinWidth and computeMinHeight on the ImageViewPane so that they return zero rather than the minimum size of the Image.
now the image goes over my grid
This is because the minimum size of your image is currently larger than the available space of the center of your BorderPane:
BorderPane does not clip its content by default, so it is possible that childrens' bounds may extend outside its own bounds if a child's min size prevents it from being fit within it space.
Some potential alternatives to prevent the center content overflowing the border:
Manually set a clip on the center node to prevent it overflowing the borders.
Dynamically resize the ImageView as in the ImageViewPane sample linked above.
Place the ImageView in a ScrollPane.
Use the css -fx-background-image attributes to display and dynamcially resize your image rather than using an ImageView.
Set the center of the borderpane first before setting the border content, that way it will be rendered underneath the border content.
Use a different construct from a borderpane (e.g. a HBoxes, VBoxes, etc.) which don't overlap their nodes when the nodes are larger than the available display area.
I tried this: imageView.fitWidthProperty().bind(box.widthProperty());
My guess from the code provided is that this didn't work because the enclosing box of the image is a dynamically resizable pane of some sort, so the minimum width of the box is being determined by the width of the image and not vice versa.
Here is what exactly I am trying to do.
I have an image with square elements inside it. When i click on top left and bottom right corners of those elements they are surrounded with divs with border. I then have functions to drag and resize those divs(once they are created by two clicks). I want to be able to record the resized coordinates of those divs in text boxes. For example if the image is with height=700 and width=500. Then if i create a square div inside it with coordinates top left(x=190,y=150) and bottom right(x=290,y=250). Then if i drag this div around the image i want those coordinates to change accordingly. Same thing to happen if i resize it.
Here i have added the code in a web site. laughter.free.bg/imagemapping/Img1.html What you need to do is click on top left and bottom right corners of one of the snack packs. Then you`ll see a box on the right with the coordinates of this Green bordered div. I want those coordinates to change when i drag or resize this div. You can see the code in the source of the page.
Thanks a lot in advance.
It is possible to bind functions to the resize event through jQuery.
For example, ur kiroid has a class of ui-resizable. You could use something like:
$('.ui-resizable').resize(function() {
// refresh your coords here from $('kiroid').css maby?
})
I'm making a product site in Adobe Edge. I have a circle div that needs to grow in a span of, let's say, 2 seconds when mouseover. Then a text has to appear in it. When mouseout, the text must disappear and do the reverse animation back to normal size. The circle has also to grow from its center, not the top left corner. I'v been trying to do this for hours with jquery and css3 animations but failed to get a satisfying result.
This is very easy with edge animate.
make your circle element.
set a key frame at 00:00 on the timeline for the circles width and height.
press Q (the transform tool) or select the icon at the top left of the screen just to the right of the arrow.
The transform tool scales things based on the origin point, which is repositionable but is automatically in the center of the selected object.
go to 02:00 on the timeline.
resize your circle.
set a keyframe for your text at 0 opacity.
go forward on the timeline.
set another keyframe for your text at 100% opacity.
group the circle and text into a div.
right click on that div and press 'convert to symbol'.
go back to the stage by clicking 'stage' on the top left of the preview window.
select the object that you want to use to trigger the animation.
open the actions for that object.
paste the following code into a mouseover event: var mySymbolObject = sym.getSymbol("INSERT THE NAME OF YOUR SYMBOL").play();
now make a mouseout event and paste this code: var mySymbolObject = sym.getSymbol("INSERT THE NAME OF YOUR SYMBOL").playReverse();
now what should happen is that onMouseOver, the timeline for that symbol plays forward, and onMouseOut, the timeline for that symbol plays in reverse. This way, if the animation is half way through and they mouse out, it will reverse from where it's at back to the beginning.
Probably you would like also to use mouseenter/mouseleave events rather than mouseover/mouseout, if you will nest text div inside circle div.
http://www.bennadel.com/blog/1805-jQuery-Events-MouseOver-MouseOut-vs-MouseEnter-MouseLeave.html
I create a UIScrollView, in which I put a UIView. Then I add some objects which are subviews of the view I added to the UIScrollView, so that I can zoom properly all the objects within the scroll.
The point is that I have an UIImageView as a subview of the mentioned view, which contains an image which is adapted to the screen size by using "imageView.contentMode = UIViewContentModeScaleAspectFit;" property.
Initially, in portrait orientation, the image fits with the screen width, so you can't scroll to left or right. When I change orientation to landscape, image fits with screen top and bottom. Then my problem. You can scroll up and down a little bit the image, as if it preserved some of the top and bottom padding from the portrait orientation.
But, if I try to zoom out, as the min zoom I setted was 1,0, the image recovers its initial size. Then you can't zoom out anymore when the zoom scale is 1.0. The 'virtual' padding is gone!
It seems as if it needed some kind of refresh.
The same happens when I keep changing orientation for portrait and landscape. It only works correctly when app loads.
I tried setting "myUIScrollView.zoom = 1.0;" in "didRotateFromInterfaceOrientation" method (when the image was not zoomed) and it worked, the 'virtual' padding again was gone.
It seems that it needs a refresh once orientation changes.
Any clue about what I'm doing wrong?
I'm have a picture box control and 2 Command Buttons. I have an image displayed inside the picture box.
Is it possible to zoom the image when the Zoom-in and Zoom out buttons are clicked?
Or I can even put a scroll bar. Is it possible to zoom the image according to the scroll bar movements?
I'm using VB 6.
I assume here that you are using BMP or JPG files here.
The simple scratch method is to place an Image control in the PictureBox, initially with the property Stretch = False. Initially, it would be in the top left hand corner. After setting the Picture property to your picture object, the Image control will be resized to fit the image. Save the original width and height of the control in variables. Now set Stretch = True. You can zoom in by resizing the image using
img.Move 0, 0, sngWidth * sngMagFactor, sngHeight * sngMagFactor
Where sngMaxFactor = 4! or however much you want to zoom by.
Restore back to original size by:
img.Move 0, 0, sngWidth, sngHeight
You can also pan the zoomed image by altering the Left and Top arguments in the Move() method.
It might be easiest to use two pic boxes, one inside the other. The 'outer' box can be thought of as a viewport into the 'inner' box, which you resize and position as needed. The effect will be the same but the coding is much simpler.