From 201bf0e4e13daadad1b8afe00edf5409256f6dbc Mon Sep 17 00:00:00 2001 From: Andrea Verlicchi Date: Sun, 16 Mar 2014 00:16:05 +0100 Subject: [PATCH] All the module variables are now assigned in the initialize function --- picturePolyfill.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/picturePolyfill.js b/picturePolyfill.js index b2d6854..c7b2d0e 100644 --- a/picturePolyfill.js +++ b/picturePolyfill.js @@ -5,8 +5,8 @@ "use strict"; var timerId, - pixelRatio = ((w.devicePixelRatio) ? Math.ceil(w.devicePixelRatio) : 1), - mediaQueriesSupported = w.matchMedia && w.matchMedia("only all") !== null && w.matchMedia("only all").matches, + pixelRatio, + mediaQueriesSupported, browserCanAppendImagesToPictures; /** @@ -173,7 +173,7 @@ } /** - * Initialize load and resize event handlers + * Initialize and resize event handlers */ function initialize() { @@ -181,6 +181,8 @@ parsePictures(document); } + pixelRatio = (w.devicePixelRatio) ? Math.ceil(w.devicePixelRatio) : 1; + mediaQueriesSupported = w.matchMedia && w.matchMedia("only all") !== null && w.matchMedia("only all").matches; browserCanAppendImagesToPictures = detectIfBrowserCanAppendImagesToPictures(); if (w.addEventListener) { @@ -201,8 +203,10 @@ } } - // Initialize and expose picturePolyfill to the global environment, to give the user the ability to call it on a slice of DOM initialize(); + + // Exposing picturePolyfill to the global environment, + // to gain the ability to call picturePolyfill on a slice of DOM (eg: after an AJAX call) w.picturePolyfill = parsePictures; }(this)); \ No newline at end of file