jQuery UI Draggable issue with containment option - jquery-ui

I'm trying to have an image inside a div of same width to be draggable in the limit of the div. It's difficult to explain but one side of the image (top or bottom) can leave the div but you cannot have a gap between the edge of the image and the border of the div.
To resume the image has the same width of the parent div but its height is bigger so a part of the image is hidden.
Well here is what I want to do:
http://jsfiddle.net/maxwell2022/DerNa/165/
It's working perfectly... because there is nothing above the div. If there is a gap between the document and the div, it's not working anymore. I think Draggable is taking the document as reference for the top of the image. As soon as you start dragging the image, the image move and stuck its top edge to the top of the document:
http://jsfiddle.net/maxwell2022/DerNa/164/
I don't know how I can achieve this with the containment option.
Cheers,
Maxime
UPDATE
Another attempt with relative positioning but no luck: http://jsfiddle.net/maxwell2022/DerNa/166/

I found a solution to fix it getting the top position of the parent div using offset() and add it to the containment boundary. I'm not sure it's the best solution but it looks like it's working.
I just have a difference of 1% in the offset at the top which is quite annoying: if you drag the image and make it stick to the top as much as possible it returns 99% offset instead of 100% (see the result in the console).
The bottom one is correct (0%). I think it's due to rounding the size but I'm not sure.
Here is the jsfiddle: http://jsfiddle.net/maxwell2022/DerNa/167/
If you have a better idea please, please, let me know.
Thanks, Maxime

Related

Flutter: Scroll, move widget, everything in the same screen

I'm trying to implement the following screen in Flutter.
It seems trivial to do so, but I couldn't find a way to achieve the same results. This is what I have so far:
My solution without scrolling
Solution following the Flutter demo but placing a map as a SliderAppBar
As you can see, I have a few problems:
This is the most accurate solution (don't look at the small blue widget moving up and down). I can move on the map and scroll through the ListView but I can't move the divider to expand the ListView. Notice that I don't want the ListView to move to the top, but until the user stops.
This one seems the correct solution but, as you can see, there are more problems: The map seems to resize instead of stay the same but just resize its container, and when I scroll down, I see the background of the Scafold.
Any ideas? This is the link to the solution 1.
PD: Sorry for the links to the GIFs. Their size was about 10MB each and I couldn't upload here.

Split screen panels (horizontal divider)

I'm trying to implement a horizontal resizable divider on a UIViewController.
Something like this sample from github (the sample is vertical, but easily adaptable to horizontal, which I already did in an Android app)
I'm pretty sure someone has already done it, but somehow seems in using the wrong keywords in my search and I have come up empty.
The idea is to have a UIWebKit on the top portion of the view, and a UITableViewController on the bottom, where both can be resized by a divider on the middle that separates them.
Here's a screenshot of the Android app... the black line in the middle is the resizable divider:
Any pointers will be appreciated!

How to apply UIView shifts when scrolling between pages

i'm trying to apply a shift effect to subviews of a UIView, but those shifts should'n have the same phase. A good example of that is the welcome screen in SoundClound.
As you can see, in the second image i'm scrolling to the second page, and the label slides more than the image (so it looks that the label moves faster than the image). So the subviews lose the alignment when scrolling, but recover it back if we stop the swipe.
Does anyone know how this effect is named? and where can i find some help to implement it?
Thanks a lot!
"Parallax scrolling" is what you want to search for.
Basically it is done by moving foreground objects faster background objects to simulate depth.
Check out http://blog.denivip.ru/index.php/2013/08/parallax-in-ios-applications/?lang=en for a starting point!

Negative margin covering links underneath

I have two divs, neither floated, and the bottom one has a negative margin on top (pulling it upwards). That bottom div is ‘covering’ some of the links in the div underneath. I need links to work in both divs, and z-index doesn’t seem to be working at all.
Again, neither div is floated, just the bottom div pulled up a bit with a negative margin on top and it’s ‘covering’ links in the div below it.
Any thoughts? Thanks!
The site in question is here: http://dawsondental.ca (see the footer)
So, I don't believe it's actually possible to allow links in both layered divs to work. I have the divs relatively positioned so that z-index works, but regardless, layered is layered. It's not possible to have useable content in layered divs. Right? If anyone knows anything I'm missing, I'm all ears.
Thanks

Container scrolling on draggable moved to left or top

is there a good way to make the container div expand to the left and top when a draggable is dragged outside of its borders?
When you drag to the right or down the container div is properly extended, and scrollbars appear as needed. Yet moving to left or top means that the draggable items has negative top / left position, so the container is not expanded.
Here's a fiddle that demonstrates the existing dragging behaviour: http://jsfiddle.net/NPC42/Un23w/1/, but this can also be seen on the official jQueryUI demos too (http://jqueryui.com/demos/draggable/#default).
I'd like to be able to expand to the top / left too :)
A brute-force approach would be to:
Reset all of the object's positions on the container div to that no negative top / left is required (including the object being dragged).
Change the scrolling position to make it look as if the objects are still on their spots.
But for many objects in the container this could cause a lot of flicker, or even slowdown, so I don't really want to go in that direction. Any suggestions are welcome!
The problem is that every html element has an absolute (0,0) origin coordinate in the top left corner. When you drag in that direction the coordinates for the dragable become negative. However the scrollbars can not become negative, their size can only grow in a positive direction.
I can imagine a custom scrollbars widget that can adjust in a negative direction when you drag below (0,0). Also try having a container inside of another container with the inner one move around so that all of the objects inside it don't have to be individually moved. I don't know of any in existence as it would be kinda weird to have a negative scroll offset.

Resources