Skip to content

Commit

Permalink
dispatch resize event when webp announcement is added
Browse files Browse the repository at this point in the history
  • Loading branch information
dugalh committed May 8, 2023
1 parent 7cba08c commit e105471
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions site/_static/scripts/browser-support.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
function dispatchEvent(type) {
// Cross browser event dispatch, adapted from
// https://stackoverflow.com/questions/26596123/internet-explorer-9-10-11-event-constructor-doesnt-work
var event;
if (typeof(Event) === 'function') {
event = new Event(type);
} else {
event = document.createEvent('Event');
event.initEvent(type, true, true);
}
document.dispatchEvent(event);
}

function webpFeatureSupport(feature, callback) {
// Test webp feature.
// 'feature' can be one of 'lossy', 'lossless', 'alpha' or 'animation'.
Expand Down Expand Up @@ -41,6 +54,9 @@ function webpSupport() {
if (!isSupported && webpSupported != false) {
webpSupported = false;
document.body.insertBefore(createAnnouncement(), document.body.firstChild);
// trigger a resize event in case there is a sticky footer that needs to
// be repositioned - see stickyFoter()
dispatchEvent("resize");
}
}
var features = ["lossy", "lossless", "alpha"];
Expand Down

0 comments on commit e105471

Please sign in to comment.