当jQuery按钮被触发时,移动站点偏离中心
Mobile site off center when jQuery button is triggered
我有一个中心问题,似乎是由我的动画滚动功能引起的。当按钮被触发时,整个站点将偏离中心,并在右侧填充。这只会发生在移动设备/触摸屏上。如果您避免使用该按钮,则不会出现任何问题。
提前感谢你的时间和帮助,我很难办!
网站截图
<div id="scroll" onclick="$('#projects').animatescroll();">
<img src="img/arrow.png" class="image" alt="scroll down" width="65px;" />
</div>
JS
(function($){
// defines various easing effects
$.easing['jswing'] = $.easing['swing'];
$.extend( $.easing,
{
def: 'easeOutQuad',
swing: function (x, t, b, c, d) {
return $.easing[$.easing.def](x, t, b, c, d);
},
easeOutQuad: function (x, t, b, c, d) {
return -c *(t/=d)*(t-2) + b;
},
});
$.fn.animatescroll = function(options) {
// fetches options
var opts = $.extend({},$.fn.animatescroll.defaults,options);
// make sure the callback is a function
if (typeof opts.onScrollStart == 'function') {
// brings the scope to the callback
opts.onScrollStart.call(this);
}
if(opts.element == "html,body") {
// Get the distance of particular id or class from top
var offset = this.offset().top;
// Scroll the page to the desired position
$(opts.element).stop().animate({ scrollTop: offset - opts.padding}, opts.scrollSpeed, opts.easing);
}
else {
// Scroll the element to the desired position
$(opts.element).stop().animate({ scrollTop: this.offset().top - this.parent().offset().top + this.parent().scrollTop() - opts.padding}, opts.scrollSpeed, opts.easing);
}
setTimeout(function() {
// make sure the callback is a function
if (typeof opts.onScrollEnd == 'function') {
// brings the scope to the callback
opts.onScrollEnd.call(this);
}
}, opts.scrollSpeed);
};
// default options
$.fn.animatescroll.defaults = {
easing:"swing",
scrollSpeed:800,
padding:0,
element:"html,body"
};
}(jQuery));
我有完全相同的问题!
我的解决办法:
body{
width:100%;
overflow:hidden;
}
相关文章:
- Javascript移动站点重定向问题
- 移动站点重定向与完整的站点链接
- window.location.href =“#find” 适用于移动设备,但不适用于 PC.在本地站点上正常(表达式
- 移动菜单需要 Jquery 2.0.1,但其他站点脚本需要旧版本
- JQuery 移动版 - 链接到外部站点,无法使用浏览器后退按钮返回页面
- 将脚本游戏移动到其他站点
- 如果访问者有移动设备,则阻止从站点加载图像.意见
- 未能执行'写入'在'文档'仅在移动站点上
- 移动站点重定向是在完整页面满载后进行的
- 移动站点检测服务器端与客户端
- 固定引用“/"当站点移动到子目录时,用于资产的(root)
- 更改服务器上的移动站点
- 我应该内联CSS &JS在移动站点,以节省带宽
- 通过更改链接中的url链接到Wordpress移动站点的确切页面
- 如何为移动站点提供更少的图像
- 在移动设备上禁用站点主体的触摸平移
- 包含页眉和页脚的jquery移动多页站点
- Facebook's移动应用/站点水平滑动菜单:Jquery插件
- 将MojoMotor站点移动到新服务器后,所有javascript资源都无法加载
- 使用浏览器检测重定向到移动站点