For mobile webkit, how can I make the horizontal menu bar scrollable when you touch/drag it? - javascript

Let's say I'm on the standard iPhone 4.
My menu bar is 2000px in width. When the user touches and holds on the menu div, he can move his finger left/right, and the menu bar will move. This allows the user to browse all of the menu's items using his finger. (Scrolling left/right)
How can I make that in javascript/jquery?
It's like the Google Images webview (go there on your phone). You're able to swipe left and right to navigate each image.
Except...I want it to be a menu bar, with no "snapping".

Here's a very very basic example. It should get you moving in the right direction though.
$('body').bind({
'touchmove': function(e){
$('.menu_bar').css({
'left': e.originalEvent.touches[0].pageX
});
}
});
To get where you're headed you'll need to also store the touchstart coordinates, the .menu_bar start position and then use a bit of math to move the bar relative to it's position rather than just snapping to the finger position each time like the example above will do.
Hope that helps :)

I'm still a little confused by the question but I believe the answer is just to use
-webkit-overflow-scrolling: touch;
This will work for iOS5 devices and give you a small scroll bar when active (i.e. when scrolling)
Otherwise you could try this plugin: http://cubiq.org/iscroll-4
Or: http://chris-barr.com/index.php/entry/scrolling_a_overflowauto_element_on_a_touch_screen_device/
(which is multi-device)

Related

Is horizontal and vertical scrolling on the same page possible?

I am trying to build a website that moves to sections using arrow keys on the keyboard or swipe on mobile/tablets. I am using FullPage. Is it possible to have a grid like website where the user can move in a square grid like fashion rather then just up and down?
It is possible. But might be much easier without fullpage.js
So you could have the page fixed but it content overflow. So that would allow you to be able to scroll at all direction.
You could add a mouse listener to scrollTo(x,y). Where x and y are the mouse pointer location

horizontal swipe list of elements like on "Google Films" search results

Is there a github or open source project which is a horizontal slider/swiper like on the google Films page?
Live Demo: https://www.google.at/search?q=films
I did a research but could not found the same behavior because this swiper does not force you to drag, on the desktop, you also can use the vertical scroll wheel and if you use the next button, it jumps to the next x elements and calculates how much it can skip depending on the screen size. Also the elements does not snap in place which is great I think, if you swipe. The cover is under your fingertip and moves as you swipe and does not do an animation or moves and snap in place, you just can swipe along.
and if you have js disabled, at least you can use the scroll wheel :)
Thx for help and tips.

On scroll animate to next div on iPad?

I have been trying to search for different things, but I couldnt find the suiting solution for my problem.
I need to scroll to the next div, when you swipe up on the iPad, so the div's top snaps to the ipads top. I think this would be simply on .scroll in combination with .scrollTop(), right? So now when you scroll, it should detect either you scroll down or up, and when you do so, jump to the next or previous div.
Has anyone a ressource, where I can find a solution to this?
Thanks in advance
I've done the exact same thing a while ago for my Personal Website. (if you check it with a tablet or a smart phone you can see it in action)
what I used was:
jQuery Mobile: to detect touch moves and unbind the scroll
Touch Swipe Plugin: to detect the direction of swipe
And the rest is simple jQuery animation using scrollTop() and offset()

Slow down/stop/pause scrolling at a specific pixel

I'm looking for a way to slow down scrolling between two specific pixels, for example 1 to 100 from the top. Would that be possible in any way?
Here's a link to a website that have that feature I'm looking for.
http://goo.gl/isH5o0
When you start scrolling the dark blue overlay div disappears using CSS3 Translate3d, but then the scroll seems to stop or go really slow, which makes the underlying div not scroll to far at the same time the overlay div slides up.
Can someone please give me a hint of what technique to use to accomplish this or maybe help me with some code.
I think that there's nothing special with the scroll on that page, just the divs moving using 3d transforms. But if you want to achieve special effects with scroll, you can use the jQuery animate function:
$('html').animate({scrollTop: position-to-scroll}, 300, 'ease-in');
More about animate.
It may be using disable scrolling. I noticed that if i drag the scroller on the right hand side of the window it is uneffected by the "slowing" however the mouse scroll is. This is similar to the effect of the demo described here How to disable scrolling temporarily? .. at a point you can temporarily disable the scroll and then re enable it to stop them going too far down

diagonal parallax with scrollto nav

I'm trying to create a site that has a parallax type effect with scrollTo navigation control.
Similar to http://www.nike.com/jumpman23/aj2012/ however I only need to scroll on left and right (up & down). I can do horizontal and vertical parallax, and scrollTo I just cant get the diagonal parallax working (with mouse scroll)
I've currently got it working using scrollTo however this disables the user being able to scroll with the mouse. I'm creating a dynamic one page site so some times a pages content may be longer then other areas so the user will need to scroll down, once they reach the end of this content the parallax effect kicks in.
Can anyone suggest a way to do this? Or point me in the right direction.

Categories