简体   繁体   English

使用iScroll的锚链接在stellar.js视差中不起作用

[英]anchor links not working in stellar.js parallax using iScroll

I have implemented parallax on a website by following the tutorial posted on the below link which uses stellar.js and iScroll for mobile : http://markdalgleish.com/2012/10/mobile-parallax-with-stellar-js/ 我已按照以下链接发布的教程在网站上实现了视差,该教程使用stellar.jsiScroll移动: http : iScroll

Everything looks good and parallax also works but the problem is that the external links that are in the page cannot be opened on iPad and mobile devices. 一切看起来不错,视差也可以,但是问题在于页面中的外部链接无法在iPad和移动设备上打开。 I was using iScroll 4 so I upgraded to iScroll 5 and adjusted the initialization calls to iScroll 5 accordingly. 我使用的是iScroll 4,因此我升级到了iScroll 5,并相应地调整了对iScroll 5的初始化调用。 Now the links open in those devices also but the performance is unbearably slow. 现在这些设备中的链接也打开了,但是性能却异常缓慢。 Is there any way to make external links open while using iScroll 4 or make the performance better while still using iScroll 5? 有什么方法可以在使用iScroll 4时打开外部链接,或者在仍使用iScroll 5时提高性能?

Apparently iScroll has some event handlers on clicking any elements inside the wrapper. 显然,iScroll具有一些单击包装器内任何元素的事件处理程序。 So I added the code to ignore clicks to any anchor tags along with select, input and textarea in the onBeforeScrollStart parameter. 因此,我在onBeforeScrollStart参数中添加了代码,以忽略对所有锚标记以及选择,输入和文本区域的onBeforeScrollStart

In order to do so replaced iScrollInstance = new iScroll('wrapper'); 为了做到这一点,更换了iScrollInstance = new iScroll('wrapper'); with the following code: 使用以下代码:

iScrollInstance = new iScroll('wrapper', {
                    handleClick: true,
                    onBeforeScrollStart: function (e) {
                        var target = e.target;
                        if (target.tagName != 'A' && target.tagName != 'SELECT' && target.tagName != 'INPUT' && target.tagName != 'TEXTAREA')
                                e.preventDefault();
                    }
                });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM