admin管理员组文章数量:1323714
I'm currently developing a web-app, that has to run on both puter systems and tablets. Possibly even smartphones. Now, the menus are on one page, horizontally next to each other. The idea is that you can switch menu by swiping the content, just like you can do on tablets and smartphones. Plus, there are buttons for puter users which will be used to switch menus.
Menu content will be loaded using JQuery's AJAX functions, and menu moving through JQuery's animate function.
Now I was wondering how I could make this animation properly. When swiping I would need to take speed, direction, and distance insto account. When clicking buttons, a static speed should be applied.
Anyone any ideas?
I'm currently developing a web-app, that has to run on both puter systems and tablets. Possibly even smartphones. Now, the menus are on one page, horizontally next to each other. The idea is that you can switch menu by swiping the content, just like you can do on tablets and smartphones. Plus, there are buttons for puter users which will be used to switch menus.
Menu content will be loaded using JQuery's AJAX functions, and menu moving through JQuery's animate function.
Now I was wondering how I could make this animation properly. When swiping I would need to take speed, direction, and distance insto account. When clicking buttons, a static speed should be applied.
Anyone any ideas?
Share Improve this question asked Nov 8, 2012 at 15:13 VenederisVenederis 1,0674 gold badges11 silver badges18 bronze badges 3- 1 While this example doesn't use JQuery nor Hammer.js, you might be able to get something out of it: jsfiddle/7etUR – Jeffrey Sweeney Commented Nov 8, 2012 at 15:33
- @JeffreySweeney - Looks good, although this is a little laggy when using it on my iPhone. Also I would prefer a Hammer/JQuery bo as those have a lot of functionality to do this already. – Venederis Commented Nov 9, 2012 at 8:25
- Why not give the jQuery.mobile gesture events a go? You can get a custom build for gesture events that has a very small footprint, and it'll tie in seamlessly with your existing jQuery click events (just replace 'click' with 'swipeleft'/'swiperight'). – monners Commented Nov 26, 2012 at 2:30
1 Answer
Reset to default 5Customizing using hammer.js is very easy. If you just go through the examples given by them, it would give you a fair idea of the functionality. However, this example will give you a sense of how the transitions will be like.
If you insist on using the animate/hammer.js, this structure will help::
$('#elementID').hammer().on('swipe', function(e){
e.preventDefault();
$('#your-content-ID').animate({
opacity: 0.25,
left: '+=50',
height: 'toggle'
}, 5000, function() {
// Animation plete.
});
});
本文标签: javascriptHow would I smoothly move an element using Hammerjs and JQueryStack Overflow
版权声明:本文标题:javascript - How would I smoothly move an element using Hammer.js and JQuery? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742128109a2422034.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论