在移动设备上禁用Jquery视差

时间:2017-02-08 14:48:28

标签: javascript jquery wordpress parallax

我很抱歉,我知道同一个问题有很多相似的主题。除了我感到困惑,因为我注意到没有用于禁用功能的通用代码。我认为JS很复杂(我不知道)。但情况就是这样。我在互联网上的某个地方找到了一个jquery代码,我想通过elementor和wordpress使用它来使背景图像也滚动(视差) 一切都很完美。唯一的问题是移动设备,效果是腐败的,看起来很糟糕,我想禁用它。这是代码:

public class SSLUtil {
    private static String KEY_STORE_TYPE = "JKS";
    private static String TRUST_STORE_TYPE = "JKS";
    private static String KEY_MANAGER_TYPE = "SunX509";
    private static String TRUST_MANAGER_TYPE = "SunX509";
    private static String PROTOCOL = "TLS";

    private static SSLContext serverSSLCtx = null;
    private static SSLContext clientSSLCtx = null;

    public static SSLContext createServerSSLContext(final String keyStoreLocation,
                                                    final String keyStorePwd)
                                                                             throws KeyStoreException,
                                                                             NoSuchAlgorithmException,
                                                                             CertificateException,
                                                                             FileNotFoundException,
                                                                             IOException,
                                                                             UnrecoverableKeyException,
                                                                             KeyManagementException {
        if (serverSSLCtx == null) {
            KeyStore keyStore = KeyStore.getInstance(KEY_STORE_TYPE);
            keyStore.load(new FileInputStream(keyStoreLocation), keyStorePwd.toCharArray());
            KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KEY_MANAGER_TYPE);
            keyManagerFactory.init(keyStore, keyStorePwd.toCharArray());
            serverSSLCtx = SSLContext.getInstance(PROTOCOL);
            serverSSLCtx.init(keyManagerFactory.getKeyManagers(), null, null);
        }

        return serverSSLCtx;
    }

    public static SSLContext createClientSSLContext(final String trustStoreLocation,
                                                    final String trustStorePwd)
                                                                               throws KeyStoreException,
                                                                               NoSuchAlgorithmException,
                                                                               CertificateException,
                                                                               FileNotFoundException,
                                                                               IOException,
                                                                               KeyManagementException {
        if (clientSSLCtx == null) {
            KeyStore trustStore = KeyStore.getInstance(TRUST_STORE_TYPE);
            trustStore.load(new FileInputStream(trustStoreLocation), trustStorePwd.toCharArray());
            TrustManagerFactory trustManagerFactory =
                                                      TrustManagerFactory.getInstance(TRUST_MANAGER_TYPE);
            trustManagerFactory.init(trustStore);
            clientSSLCtx = SSLContext.getInstance(PROTOCOL);
            clientSSLCtx.init(null, trustManagerFactory.getTrustManagers(), null);
        }

        return clientSSLCtx;

    }

}

谢谢

2 个答案:

答案 0 :(得分:0)

if (!testMobile) {
        $(".parallax").parallax("50%", 0.3);
}

你不需要检查null,你想检查它是否为(!)true。

顺便说一下,“禁用功能似乎非常复杂”:

yourfunctiontodisable=()=>console.log("disabled function called");

答案 1 :(得分:0)

只需编辑您的移动设备宽度即可。现在,视差仅适用于991px以上的设备。

if (window_width > 991) {
    $(".parallax").parallax("50%", 0.3);
});