{"id":588,"date":"2019-07-30T02:57:47","date_gmt":"2019-07-30T02:57:47","guid":{"rendered":"http:\/\/info.juliusgoh.life\/?p=588"},"modified":"2019-07-30T03:40:37","modified_gmt":"2019-07-30T03:40:37","slug":"jquery-check-device-width-of-device-check-element-is-in-middle-of-screen-when-scrolled","status":"publish","type":"post","link":"https:\/\/info.juliusgoh.life\/?p=588","title":{"rendered":"Jquery Check Device &#038; width of device &#038; check element is in middle of screen when scrolled"},"content":{"rendered":"<pre>&lt;script&gt;\r\nif( \/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini\/i.test(navigator.userAgent) ) {\r\n    var window_width = $(window).width();\r\n    if(window_width &lt;= 991){\r\n        console.log(\"Mobile Devices width is smaller than 991\");\r\n        var windowHeight = $(window).height(),\r\n            gridTop = windowHeight * .3,\r\n            gridBottom = windowHeight * .8;\r\n \r\n        $(window).scroll(function(){\r\n            $.each($(\"[class$=area]\"),function(){\r\n                var thisTop = $(this).offset().top - $(window).scrollTop();\r\n\r\n                if (thisTop &gt; gridTop &amp;&amp; (thisTop + $(this).height()) &lt; gridBottom) {\r\n                    if($(this).css(\"bottom\") != \"0px\"){\r\n                        $(this).css(\"bottom\", \"0px\");\r\n                    }\r\n                } else {\r\n                    if($(this).css(\"bottom\") == \"0px\"){\r\n                        $(this).css(\"bottom\", \"-105px\");\r\n                    }\r\n                }\r\n            });\r\n        });\r\n    }\r\n}\r\n&lt;\/script&gt;\r\n<\/pre>\n<p>REF : <a href=\"https:\/\/jsfiddle.net\/atcwL1mz\/\">https:\/\/jsfiddle.net\/atcwL1mz\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&lt;script&gt; if( \/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini\/i.test(navigator.userAgent) ) { var window_width = $(window).width(); if(window_width &lt;= 991){ console.log(&#8220;Mobile Devices width is smaller than 991&#8221;); var windowHeight = $(window).height(), gridTop = windowHeight * .3, gridBottom = windowHeight * .8; $(window).scroll(function(){ $.each($(&#8220;[class$=area]&#8221;),function(){ var thisTop = $(this).offset().top &#8211; $(window).scrollTop(); if (thisTop &gt; gridTop &amp;&amp; (thisTop + $(this).height()) &lt; gridBottom) { if($(this).css(&#8220;bottom&#8221;) != [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":590,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"image","meta":{"footnotes":""},"categories":[8,5],"tags":[],"_links":{"self":[{"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=\/wp\/v2\/posts\/588"}],"collection":[{"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=588"}],"version-history":[{"count":3,"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=\/wp\/v2\/posts\/588\/revisions"}],"predecessor-version":[{"id":592,"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=\/wp\/v2\/posts\/588\/revisions\/592"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=\/wp\/v2\/media\/590"}],"wp:attachment":[{"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=588"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=588"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=588"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}