Bug fix: can not click on the tab bar of ionic framework
Possibly related issues are:
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.1.2-beta-20171130-1100" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
+<plugin id="cordova-plugin-googlemaps" version="2.1.2-beta-20171206-1705" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>cordova-plugin-googlemaps</name>
<js-module name="BaseClass" src="www/BaseClass.js">
<runs />

MODIFY
www/Common.js
www/Common.js
@@ -281,7 +281,7 @@ function _clearInternalCache() {
function _removeCacheById(elemId) {
delete internalCache[elemId];
}
-function getZIndex(dom, floorLevel, solt) {
+function getZIndex(dom, solt) {
if (dom === document.body) {
internalCache = undefined;
internalCache = {};
@@ -305,11 +305,10 @@ function getZIndex(dom, floorLevel, solt) {
if (parentElemId in internalCache) {
parentZIndex = internalCache[parentElemId];
} else {
- parentZIndex = getZIndex(dom.parentNode, floorLevel - 1, solt);
+ parentZIndex = getZIndex(dom.parentNode, solt);
internalCache[parentElemId] = parentZIndex;
}
}
- dom.setAttribute("__parentZIndex", parentZIndex);
if (z === "auto") {
z = 1;
@@ -320,20 +319,19 @@ function getZIndex(dom, floorLevel, solt) {
} else {
z = parseInt(z);
}
- internalCache[elemId] = z + parentZIndex;
-
-dom.setAttribute("__zindex", z);
+ dom.setAttribute("__parentZIndex", parentZIndex);
dom.setAttribute("__solt", solt);
-
+ dom.setAttribute("__ZIndex", z);
+ internalCache[elemId] = z + parentZIndex;
return z;
}
-function getDomDepth(dom, idx, zIndex, floorLevel, zIndexSolt) {
+function getDomDepth(dom, idx, zIndex) {
if (dom.nodeType !== Node.ELEMENT_NODE) {
return 0;
}
- // In order to handle this value as double anytime, add 0.01 (for Android)
- var result = (zIndex) + 0.01;
+ var result = (zIndex) + (idx / (1 << Math.pow(idx, idx)) / 10);
+ /* for debug */
var currentDepth = parseFloat(dom.getAttribute("_depth")) || 0;
if (currentDepth != result) {
dom.setAttribute("_depth", result); // for debugging

MODIFY
www/googlemaps-cdv-plugin.js
www/googlemaps-cdv-plugin.js
@@ -163,11 +163,16 @@ if (!cordova) {
}
}
- document.body.addEventListener("transitionend", function() {
+ document.body.addEventListener("transitionend", function(e) {
+ if (e.target.hasAttribute("__pluginDomId")) {
+ var elemId = e.target.getAttribute("__pluginDomId");
+ removeDomTree(e.target, {
+ keepDomId: true
+ });
+ }
resetTimer({force: true});
}, true);
- document.body.addEventListener("followMapDivPositionOnly",followMapDivPositionOnly, true);
document.body.addEventListener("scroll", function(e) {
if (e.target.hasAttribute("__pluginDomId")) {
var elemId = e.target.getAttribute("__pluginDomId");
@@ -192,9 +197,7 @@ if (!cordova) {
function removeDomTree(node, options) {
options = options || {};
var children = node.querySelectorAll('[__pluginDomId]');
- if (!children || children.length === 0) {
- return;
- }
+ if (children && children.length > 0) {
children.forEach(function(child) {
var elemId = child.getAttribute('__pluginDomId');
if (!options.keepDomId) {
@@ -213,6 +216,7 @@ if (!cordova) {
delete cacheDepth[elemId];
delete prevFinal[elemId];
});
+ }
if (node.hasAttribute("__pluginDomId")) {
var elemId = node.getAttribute('__pluginDomId');
if (!options.keepDomId) {
@@ -242,6 +246,7 @@ if (!cordova) {
return;
}
var observer = new MutationObserver(function(mutations) {
+ common.nextTick(function() {
mutations.forEach(function(mutation) {
var targetCnt = 0;
if (mutation.type === "childList") {
@@ -270,13 +275,14 @@ if (!cordova) {
common.nextTick(putHtmlElements);
}
} else {
- if (mutation.target.nodeType !== Node.ELEMENT_NODE ||
- !mutation.target.hasAttribute("__pluginDomId")) {
+ if (mutation.target.nodeType !== Node.ELEMENT_NODE) {
return;
}
+ if (mutation.target.hasAttribute("__pluginDomId")) {
removeDomTree(mutation.target, {
keepDomId: true
});
+ }
isThereAnyChange = true;
idlingCnt = -1;
longIdlingCnt = -1;
@@ -287,6 +293,7 @@ if (!cordova) {
});
});
+ });
observer.observe(document.body.parentElement, {
attributes : true,
childList: true,
@@ -387,7 +394,7 @@ if (!cordova) {
bodyRect.bottom = bodyRect.top + bodyRect.heihgt;
common._clearInternalCache();
- traceDomTree(document.body, 0, bodyRect, 0, 0, 1, 0);
+ traceDomTree(document.body, 0, bodyRect, 0, 0, 0);
// If some elements has been removed, should update the positions
var elementCnt = Object.keys(domPositions).length;
@@ -537,12 +544,11 @@ if (!cordova) {
children = null;
}
- function traceDomTree(element, domIdx, parentRect, parentZIndex, parentDepth, floorLevel, zIndexSolt) {
+ function traceDomTree(element, domIdx, parentRect, parentZIndex, parentDepth, zIndexSolt) {
var zIndex = parentZIndex;
doNotTrace = false;
var depth = 1;
var elemId;
- var calcZindex;
if (common.shouldWatchByNative(element)) {
@@ -554,23 +560,23 @@ if (!cordova) {
}
// get dom depth
- zIndex = common.getZIndex(element, floorLevel, zIndexSolt);
+ zIndex = common.getZIndex(element, zIndexSolt);
if (zIndex === 0) {
zIndexSolt++;
}
- calcZindex = zIndex / (1 << zIndexSolt);
- calcZindex += parentZIndex;
+ zIndex = zIndex / (1 << (Math.pow(zIndexSolt, zIndexSolt)));
+ zIndex += parentZIndex;
var rect;
if (elemId in cacheDepth &&
elemId in prevDomPositions &&
- prevDomPositions[elemId].zIndex === calcZindex) {
+ prevDomPositions[elemId].zIndex === zIndex) {
depth = cacheDepth[elemId];
} else {
- //if (parentDepth > MAX_MAP_DEPTH && MAX_MAP_DEPTH !== -1) {
- // depth = parentDepth;
- //} else {
- depth = common.getDomDepth(element, domIdx, zIndex, floorLevel, zIndexSolt);
- //}
+ if (parentDepth > MAX_MAP_DEPTH && MAX_MAP_DEPTH !== -1) {
+ depth = parentDepth;
+ } else {
+ depth = common.getDomDepth(element, domIdx, zIndex);
+ }
cacheDepth[elemId] = depth;
}
// Calculate dom clickable region
@@ -622,22 +628,27 @@ if (!cordova) {
}
// get dom depth
- zIndex = common.getZIndex(element, floorLevel, zIndexSolt);
+ zIndex = common.getZIndex(element, zIndexSolt);
if (zIndex === 0) {
zIndexSolt++;
}
- calcZindex = zIndex / (1 << zIndexSolt);
- calcZindex += parentZIndex;
+ zIndex = zIndex / (1 << (Math.pow(zIndexSolt, zIndexSolt)));
+ zIndex += parentZIndex;
if (elemId in cacheDepth &&
elemId in prevDomPositions &&
- prevDomPositions[elemId].zIndex === calcZindex) {
+ prevDomPositions[elemId].zIndex === zIndex) {
depth = cacheDepth[elemId];
} else {
- depth = common.getDomDepth(element, domIdx, calcZindex, floorLevel, zIndexSolt);
+ depth = common.getDomDepth(element, domIdx, zIndex);
cacheDepth[elemId] = depth;
}
}
}
+ if (doNotTrace) {
+ removeDomTree(element, {
+ keepDomId: true
+ });
+ }
} else {
doNotTrace = true;
}
@@ -652,7 +663,7 @@ if (!cordova) {
common.getStyle(child, "display") === "none") {
continue;
}
- traceDomTree(child, domIdx + i + 1, parentRect, zIndex, depth, floorLevel + 1, zIndexSolt);
+ traceDomTree(child, domIdx + i + 1, parentRect, zIndex, depth, zIndexSolt);
}
}
}

Bug fix: can not click on the tab bar of ionic framework #1930

Possibly related issues are:
https://github.com/mapsplugin/cordova-plugin-googlemaps/issues/1920
https://github.com/mapsplugin/cordova-plugin-googlemaps/issues/1919
https://github.com/mapsplugin/cordova-plugin-googlemaps/issues/1927