From de1dc6794ebe4686b3e680ea0510e190a88b1e04 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 13 Apr 2017 19:13:08 +0200 Subject: [PATCH] #1346 --- js/libs/orientationchangeend.js | 93 --------------------------------- 1 file changed, 93 deletions(-) delete mode 100644 js/libs/orientationchangeend.js diff --git a/js/libs/orientationchangeend.js b/js/libs/orientationchangeend.js deleted file mode 100644 index df18b86e..00000000 --- a/js/libs/orientationchangeend.js +++ /dev/null @@ -1,93 +0,0 @@ -var Event, - Sister = require('sister'); - -Event = function Event (config) { - var event, - lastEnd, - eventEmitter; - - if (!(this instanceof Event)) { - return new Event(config); - } - - eventEmitter = Sister(); - - event = this; - event.on = eventEmitter.on; - - config = config || {}; - - /** - * @var {Number} Number of iterations the subject of interval inspection must not mutate to fire "orientationchangeend". - */ - config.noChangeCountToEnd = config.noChangeCountToEnd || 100; - /** - * @var {Number} Number of milliseconds after which fire the "orientationchangeend" if interval inspection did not do it before. - */ - config.noEndTimeout = 1000 || config.noEndTimeout; - /** - * @var {Boolean} Enables logging of the events. - */ - config.debug = config.debug || false; - - global - .addEventListener('orientationchange', function () { - var interval, - timeout, - end, - lastInnerWidth, - lastInnerHeight, - noChangeCount; - - end = function (dispatchEvent) { - clearInterval(interval); - clearTimeout(timeout); - - interval = null; - timeout = null; - - if (dispatchEvent) { - eventEmitter.trigger('orientationchangeend'); - } - }; - - // If there is a series of orientationchange events fired one after another, - // where n event orientationchangeend event has not been fired before the n+2 orientationchange, - // then orientationchangeend will fire only for the last orientationchange event in the series. - if (lastEnd) { - lastEnd(false); - } - - lastEnd = end; - - interval = setInterval(function () { - if (global.innerWidth === lastInnerWidth && global.innerHeight === lastInnerHeight) { - noChangeCount++; - - if (noChangeCount === config.noChangeCountToEnd) { - if (config.debug) { - console.debug('setInterval'); - } - - end(true); - } - } else { - lastInnerWidth = global.innerWidth; - lastInnerHeight = global.innerHeight; - noChangeCount = 0; - } - }); - timeout = setTimeout(function () { - if (config.debug) { - console.debug('setTimeout'); - } - - end(true); - }, config.noEndTimeout); - }); -} - -global.gajus = global.gajus || {}; -global.gajus.orientationchangeend = Event; - -module.exports = Event; \ No newline at end of file -- 2.39.5