[{"data":1,"prerenderedAt":227},["ShallowReactive",2],{"snippets-tag-javascript":3},[4,105,165],{"_path":5,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":9,"description":10,"createdAt":11,"tags":12,"body":15,"_type":99,"_id":100,"_source":101,"_file":102,"_stem":103,"_extension":104},"/snippets/safari-back-forward-cache-override","snippets",false,"","Safari back-forward-cache override",null,"05/03/2024",[13,14],"javascript","safari",{"type":16,"children":17,"toc":95},"root",[18,63,70],{"type":19,"tag":20,"props":21,"children":24},"element","div",{"className":22},[23],"c-code-wrapper",[25,28,50],{"type":26,"value":27},"text","\n  ",{"type":19,"tag":20,"props":29,"children":32},{"className":30},[31],"c-code-wrapper__header",[33,35,41,42,49],{"type":26,"value":34},"\n    ",{"type":19,"tag":20,"props":36,"children":39},{"className":37},[38],"c-code-wrapper__title",[40],{"type":26,"value":9},{"type":26,"value":34},{"type":19,"tag":20,"props":43,"children":46},{"className":44},[45],"c-code-wrapper__copy",[47],{"type":26,"value":48},"Copy",{"type":26,"value":27},{"type":19,"tag":51,"props":52,"children":57},"pre",{"className":53,"code":55,"filename":56,"language":56,"meta":8},[54],"language-js","// Safari back-forward-cache override\n(function () {\n  window.onpageshow = function (event) {\n    if (event.persisted) {\n      document.body.style.opacity = 0;\n      window.location.reload();\n    }\n  };\n})();\n","js",[58],{"type":19,"tag":59,"props":60,"children":61},"code",{"__ignoreMap":8},[62],{"type":26,"value":55},{"type":19,"tag":64,"props":65,"children":67},"h2",{"id":66},"further-reading",[68],{"type":26,"value":69},"Further reading",{"type":19,"tag":71,"props":72,"children":73},"ul",{},[74,86],{"type":19,"tag":75,"props":76,"children":77},"li",{},[78],{"type":19,"tag":79,"props":80,"children":84},"a",{"href":81,"rel":82},"https://stackoverflow.com/a/13123626/5527156",[83],"nofollow",[85],{"type":26,"value":81},{"type":19,"tag":75,"props":87,"children":88},{},[89],{"type":19,"tag":79,"props":90,"children":93},{"href":91,"rel":92},"https://web.dev/articles/bfcache",[83],[94],{"type":26,"value":91},{"title":8,"searchDepth":96,"depth":96,"links":97},2,[98],{"id":66,"depth":96,"text":69},"markdown","content:snippets:safari-back-forward-cache-override.md","content","snippets/safari-back-forward-cache-override.md","snippets/safari-back-forward-cache-override","md",{"_path":106,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":107,"description":10,"createdAt":11,"tags":108,"body":110,"_type":99,"_id":162,"_source":101,"_file":163,"_stem":164,"_extension":104},"/snippets/show-all-non-native-window-properties","Get all non native window variables",[13,109],"window",{"type":16,"children":111,"toc":159},[112,143,147],{"type":19,"tag":20,"props":113,"children":115},{"className":114},[23],[116,117,134],{"type":26,"value":27},{"type":19,"tag":20,"props":118,"children":120},{"className":119},[31],[121,122,127,128,133],{"type":26,"value":34},{"type":19,"tag":20,"props":123,"children":125},{"className":124},[38],[126],{"type":26,"value":107},{"type":26,"value":34},{"type":19,"tag":20,"props":129,"children":131},{"className":130},[45],[132],{"type":26,"value":48},{"type":26,"value":27},{"type":19,"tag":51,"props":135,"children":138},{"className":136,"code":137,"filename":56,"language":56,"meta":8},[54],"// Get all non native window variables\n\n(function showAllNonNativeWindowProperties() {\n  const iframe = document.createElement(\"iframe\");\n  iframe.style.display = \"none\";\n  document.body.appendChild(iframe);\n\n  const currentWindowProps = Object.getOwnPropertyNames(window);\n\n  const allNonNativeProps = currentWindowProps.filter(function (prop) {\n    return !iframe.contentWindow.hasOwnProperty(prop);\n  });\n\n  for (const prop of allNonNativeProps.sort()) {\n    console.log(`Saabbir ${prop}: `, window[`${prop}`]);\n  }\n\n  document.body.removeChild(iframe);\n})();\n",[139],{"type":19,"tag":59,"props":140,"children":141},{"__ignoreMap":8},[142],{"type":26,"value":137},{"type":19,"tag":64,"props":144,"children":145},{"id":66},[146],{"type":26,"value":69},{"type":19,"tag":71,"props":148,"children":149},{},[150],{"type":19,"tag":75,"props":151,"children":152},{},[153],{"type":19,"tag":79,"props":154,"children":157},{"href":155,"rel":156},"https://stackoverflow.com/questions/17246309/get-all-user-defined-window-properties",[83],[158],{"type":26,"value":155},{"title":8,"searchDepth":96,"depth":96,"links":160},[161],{"id":66,"depth":96,"text":69},"content:snippets:show-all-non-native-window-properties.md","snippets/show-all-non-native-window-properties.md","snippets/show-all-non-native-window-properties",{"_path":166,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":167,"description":168,"createdAt":169,"tags":170,"body":171,"_type":99,"_id":224,"_source":101,"_file":225,"_stem":226,"_extension":104},"/snippets/detect-horizontal-swipe","Detect Horizontal Swipe","Detect horizontal (left/right) swipe on mobile.","01/01/2021",[13],{"type":16,"children":172,"toc":221},[173,205,209],{"type":19,"tag":20,"props":174,"children":176},{"className":175},[23],[177,178,196],{"type":26,"value":27},{"type":19,"tag":20,"props":179,"children":181},{"className":180},[31],[182,183,189,190,195],{"type":26,"value":34},{"type":19,"tag":20,"props":184,"children":186},{"className":185},[38],[187],{"type":26,"value":188},"Detect horizontal swipe",{"type":26,"value":34},{"type":19,"tag":20,"props":191,"children":193},{"className":192},[45],[194],{"type":26,"value":48},{"type":26,"value":27},{"type":19,"tag":51,"props":197,"children":200},{"className":198,"code":199,"filename":56,"language":56,"meta":8},[54],"// Detect horizontal swipe\n!(function detectHorizontalSwipe() {\n  let touchstartX = 0;\n  let touchendX = 0;\n\n  const body = document.querySelector(\"body\");\n\n  function handleGesture() {\n    if (touchendX \u003C touchstartX) alert(\"swiped left!\");\n    if (touchendX > touchstartX) alert(\"swiped right!\");\n  }\n\n  body.addEventListener(\"touchstart\", (e) => {\n    touchstartX = e.changedTouches[0].screenX;\n  });\n\n  body.addEventListener(\"touchend\", (e) => {\n    touchendX = e.changedTouches[0].screenX;\n    handleGesture();\n  });\n})();\n",[201],{"type":19,"tag":59,"props":202,"children":203},{"__ignoreMap":8},[204],{"type":26,"value":199},{"type":19,"tag":64,"props":206,"children":207},{"id":66},[208],{"type":26,"value":69},{"type":19,"tag":71,"props":210,"children":211},{},[212],{"type":19,"tag":75,"props":213,"children":214},{},[215],{"type":19,"tag":79,"props":216,"children":219},{"href":217,"rel":218},"https://stackoverflow.com/questions/2264072/detect-a-finger-swipe-through-javascript-on-the-iphone-and-android",[83],[220],{"type":26,"value":217},{"title":8,"searchDepth":96,"depth":96,"links":222},[223],{"id":66,"depth":96,"text":69},"content:snippets:detect-horizontal-swipe.md","snippets/detect-horizontal-swipe.md","snippets/detect-horizontal-swipe",1788788972763]