Skip to content

Commit 02f4311

Browse files
committed
test release
1 parent 0dce451 commit 02f4311

File tree

1 file changed

+39
-15
lines changed

1 file changed

+39
-15
lines changed

src/DGCustomization/src/DGMobileImprove.js

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,28 @@ L.MobileTileLayer = L.TileLayer.extend({
357357
return true;
358358
},
359359

360+
_isAppleDevice: function() {
361+
var appleMobileRE = /ip(hone|od)/i; // Для iPhone и iPod
362+
var appleTabletRE = /ipad/i; // Для iPad
363+
var touchMacRE = /Macintosh/i; // Для устройств macOS с тач-экранами
364+
365+
var ua = typeof navigator !== 'undefined' ? navigator.userAgent : '';
366+
367+
if (!ua) {
368+
return false;
369+
}
370+
371+
// Проверяем iPhone, iPod и iPad
372+
var isAppleMobile = appleMobileRE.test(ua);
373+
var isAppleTablet = appleTabletRE.test(ua);
374+
375+
// Проверяем macOS с тач-скрином (например, iPadOS, который может определяться как Mac)
376+
var isTouchMac =
377+
navigator.maxTouchPoints > 1 && touchMacRE.test(ua) && ua.indexOf('Safari') !== -1;
378+
379+
return isAppleMobile || isAppleTablet || isTouchMac;
380+
},
381+
360382
/**
361383
* Добавлена логика с превью тайлами
362384
*/
@@ -368,7 +390,8 @@ L.MobileTileLayer = L.TileLayer.extend({
368390
var needPreview = this._needPreviewTile(wrapCoords);
369391

370392
var url = needPreview ? this._previewUrl : this._url;
371-
var tile = this.createTile(wrapCoords, L.bind(needPreview ? this._previewReady : this._tileReady, this, coords), url);
393+
var showPreviewForIphone = this._isAppleDevice() && needPreview;
394+
var tile = this.createTile(wrapCoords, L.bind(showPreviewForIphone ? this._previewReady : this._tileReady, this, coords), url);
372395

373396
this._initTile(tile);
374397

@@ -426,23 +449,24 @@ L.MobileTileLayer = L.TileLayer.extend({
426449
tile = this._tiles[key];
427450
if (!tile) { return; }
428451

452+
if (!this._isAppleDevice()) {
429453
// Если у тайла уже есть оригинальная (не пожатая) картинка,
430454
// то заменим превью на нее
431-
if (tile.originalEl && tile.el.parentNode) {
432-
tile.el.parentNode.replaceChild(tile.originalEl, tile.el);
433-
tile.el = tile.originalEl;
434-
435-
tile.originalEl = null;
436-
tile.preview = false;
437-
438-
// Если у тайла есть только превью, то добавим его на карту
439-
// И начнем грузить оригинальный
440-
} else if (tile.preview) {
441-
tile.originalEl = this.createTile(this._wrapCoords(coords), L.bind(this._tileReady, this, coords), this._url);
442-
this._initTile(tile.originalEl);
443-
L.DomUtil.setPosition(tile.originalEl, this._getTilePos(coords));
455+
if (tile.originalEl && tile.el.parentNode) {
456+
tile.el.parentNode.replaceChild(tile.originalEl, tile.el);
457+
tile.el = tile.originalEl;
458+
459+
tile.originalEl = null;
460+
tile.preview = false;
461+
462+
// Если у тайла есть только превью, то добавим его на карту
463+
// И начнем грузить оригинальный
464+
} else if (tile.preview) {
465+
tile.originalEl = this.createTile(this._wrapCoords(coords), L.bind(this._tileReady, this, coords), this._url);
466+
this._initTile(tile.originalEl);
467+
L.DomUtil.setPosition(tile.originalEl, this._getTilePos(coords));
468+
}
444469
}
445-
446470
tile.loaded = +new Date();
447471
tile.active = true;
448472
this._pruneTiles();

0 commit comments

Comments
 (0)