Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Do not compute origHtmlMargin and scale if not needed #100

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions jquery.smartbanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/
!function ($) {
var SmartBanner = function (options) {
this.origHtmlMargin = parseFloat($('html').css('margin-top')) // Get the original margin-top of the HTML element so we can take that into account
this.options = $.extend({}, $.smartbanner.defaults, options)

var standalone = navigator.standalone // Check if it's already a standalone web app or running within a webui view of an app (not mobile safari)
Expand All @@ -31,15 +30,17 @@
return
}

// Calculate scale
this.scale = this.options.scale == 'auto' ? $(window).width() / window.screen.width : this.options.scale
if (this.scale < 1) this.scale = 1

// Get info from meta data
var meta = $(this.type == 'android' ? 'meta[name="google-play-app"]' :
this.type == 'ios' ? 'meta[name="apple-itunes-app"]' :
this.type == 'kindle' ? 'meta[name="kindle-fire-app"]' : 'meta[name="msApplication-ID"]');
if (meta.length == 0) return

this.origHtmlMargin = parseFloat($('html').css('margin-top')) // Get the original margin-top of the HTML element so we can take that into account

// Calculate scale
this.scale = this.options.scale == 'auto' ? $(window).width() / window.screen.width : this.options.scale
if (this.scale < 1) this.scale = 1

// For Windows Store apps, get the PackageFamilyName for protocol launch
if (this.type == 'windows') {
Expand Down