为什么in-viewport javascript在我的代码中不起作用?

时间:2016-10-31 04:29:48

标签: javascript jquery html css

为什么[16-10-30 21:25:51:325 PDT] { "error": { "code": 400, "message": "Invalid JSON payload received. Unknown name \"reportRequests\": Cannot bind query parameter. 'reportRequests' is a message type. Parameters can only be bound to primitive types.", "status": "INVALID_ARGUMENT", "details": [ { "@type": "type.googleapis.com/google.rpc.BadRequest", "fieldViolations": [ { "description": "Invalid JSON payload received. Unknown name \"reportRequests\": Cannot bind query parameter. 'reportRequests' is a message type. Parameters can only be bound to primitive types." } ] } ] } } javascript在我的代码中不起作用?

https://jsfiddle.net/vncxfx0s/30/

点击in-viewport猫图像会滑动它没问题。

但是当我填写代码时

Click to move

要检测 if($("#testtest").is(":in-viewport")) { alert("hhh"); } 在视口中显示的时间,它应该是警惕。

但它什么都不起作用,我该怎么办?

id="testtest"

1 个答案:

答案 0 :(得分:0)

因为您需要为https://jsfiddle.net/vncxfx0s/31/

启用jquery
  <script>
function left_fn(value) {
    if($("#testtest").is(":in-viewport"))
    {
        alert("hhh");
    }
    document.getElementById("cat-ul").style.transform = "translate3d("+value+"px, 0px, 0px)";
    var x = (value + 422);
    var y = (value - 422);
    document.getElementById('move-left').setAttribute('onclick','left_fn('+y+')')
}
</script>