SHARE
TWEET

Untitled

a guest Jul 17th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var is_keyboard = false;
  2. var is_landscape = false;
  3. var initial_screen_size = window.innerHeight;
  4.  
  5. /* Android */
  6. window.addEventListener("resize", function() {
  7.     is_keyboard = (window.innerHeight < initial_screen_size);
  8.     is_landscape = (screen.height < screen.width);
  9.  
  10.     updateViews();
  11. }, false);
  12.  
  13. /* iOS */
  14. $("input").bind("focus blur",function() {
  15.     $(window).scrollTop(10);
  16.     is_keyboard = $(window).scrollTop() > 0;
  17.     $(window).scrollTop(0);
  18.     updateViews();
  19. });
  20.      
  21. function updateViews() {
  22.     $("li").hide();
  23.     if (is_keyboard) {
  24.         $("#logo").hide();
  25.         if (is_landscape) {
  26.             $("li").slice(0, 2).show();
  27.         }
  28.         else {
  29.             $("li").slice(0, 4).show();
  30.         }
  31.     }
  32.     else {
  33.         $("#logo").show();
  34.         $("li").show();
  35.     }
  36. }
  37.      
  38. <div id="logo">Logo</div>
  39. <input type="text"><input type="submit" value="search">
  40. <ul>
  41.     <li>Item</li>
  42.     <li>Item</li>
  43.     <li>Item</li>
  44.     <li>Item</li>
  45.     <li>Item</li>
  46.     <li>Item</li>
  47.     <li>Item</li>
  48.     <li>Item</li>
  49. </ul>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top