脚本未在Semplice上加载

时间:2018-08-29 17:36:00

标签: javascript jquery wordpress

我的Semplice产品组合中有一些JavaScript http://kevcharlton.co.uk/project/delete-graduates

脚本可以使徽标在滚动时旋转。永远不会在首次加载时起作用,但始终会在页面刷新时起作用。

我的一位同事说我需要研究添加诸如     '$(document).ready()' 但是我是一个真正的菜鸟,我也不知道怎么做。

JavaScript非常简单。

CREATE OR REPLACE FUNCTION data.polygons_as_geojson(
    IN _north double precision,
    IN _east double precision,
    IN _south double precision,
    IN _west double precision,
    OUT plg json
)
RETURNS json AS
$BODY$
    BEGIN
        SELECT row_to_json(fc.*) as polygons into plg
        FROM
        (
            SELECT 'FeatureCollection' AS type,
            array_to_json(array_agg(f.*)) AS features
            FROM
            (
                SELECT 'Feature' AS type,
                (
                    SELECT row_to_json(t) as properties
                    FROM
                    (
                        SELECT id, pid, ptype, pdate, pdepartment, pgrid, pgeoid, pprojectname, psalesstream, pclient FROM data.polygons WHERE id = dp.id 
                    ) t
                ),
                ST_AsGeoJSON(geom,7)::json as geometry
                FROM data.polygons  dp WHERE ST_SetSRID(ST_MakeBox2D(ST_Point(_west, _south), ST_Point(_east, _north)),4326) && geom
            ) f
        ) fc;
        return;
    END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;

有人可以帮助吗?

我也无法在首页http://kevcharlton.co.uk上使用它-但是我认为这可能与滚动劫持有关。

谢谢!

1 个答案:

答案 0 :(得分:0)

根据加载顺序,您可能需要等待DOM加载完毕,因为在执行时,您的元素可能还不存在。

// wait until DOM has been loaded
document.addEventListener("DOMContentLoaded", function() {
    var logo = document.querySelector('.logo img');
    logo.style.transformOrigin = 'center center';

    window.addEventListener('scroll', function() {
        logo.style.transform = 'rotate('+(window.scrollY*0.3)+'deg)';
    });
});