From 9a89ebe215ce9654cf0380af7e826537f3c7fcab Mon Sep 17 00:00:00 2001 From: s1n Date: Thu, 24 Oct 2019 13:24:51 -0700 Subject: Create refresh-on-media.js --- js/refresh-on-media.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 js/refresh-on-media.js diff --git a/js/refresh-on-media.js b/js/refresh-on-media.js new file mode 100644 index 0000000..76bb6da --- /dev/null +++ b/js/refresh-on-media.js @@ -0,0 +1,24 @@ +var context; +var $window = $(window); + +// run this right away to set context +if ($window.width() <= 768) { + context = 'small'; +} else if (768 < $window.width() < 970) { + context = 'medium'; +} else { + context = 'large'; +} + +// refresh the page only if you're crossing into a context +// that isn't already set +$(window).resize(function() { + if(($window.width() <= 768) && (context != 'small')) { + //refresh the page + location.reload(); + } else if ((768 < $window.width() < 970) && (context != 'medium')) { + location.reload(); + } else if (context != 'large') { + location.reload(); + } +}); -- cgit v1.2.3