-
-
Save csavoronin/c7b2dd8cd77e769ddd7a1a8e46bd3ab0 to your computer and use it in GitHub Desktop.
[!] JS: Event 'ce.needScroll' was attached several times. Fixed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 3a42e28e7c721f8a07aee58c8337b362215f4757 Mon Sep 17 00:00:00 2001 | |
From: Andrei Voronin <avoronin@avoronin.u.simtech> | |
Date: Thu, 19 Sep 2019 12:25:05 +0400 | |
Subject: [PATCH] [!] {@24636}: JS: Event 'ce.needScroll' was attached several | |
times. Fixed. | |
--- | |
js/core/src/core/Tygh/core_methods.js | 11 +++++++++-- | |
js/tygh/responsive.js | 13 ++++++++----- | |
2 files changed, 17 insertions(+), 7 deletions(-) | |
diff --git a/js/core/src/core/Tygh/core_methods.js b/js/core/src/core/Tygh/core_methods.js | |
index 8386845846..987650524d 100644 | |
--- a/js/core/src/core/Tygh/core_methods.js | |
+++ b/js/core/src/core/Tygh/core_methods.js | |
@@ -298,13 +298,20 @@ export const dispatchEvent = function(e) | |
var opt = { | |
need_scroll: true, | |
- jelm: _e | |
+ jelm: _e, | |
+ timeout: 0 | |
}; | |
$.ceEvent('trigger', 'ce.needScroll', [opt]); | |
if (_e.data('caScroll') && opt.need_scroll) { | |
- $.scrollToElm(_e.data('caScroll')); | |
+ if (opt.timeout) { | |
+ setTimeout(function () { | |
+ $.scrollToElm(_e.data('caScroll')); | |
+ }, opt.timeout); | |
+ } else { | |
+ $.scrollToElm(_e.data('caScroll')); | |
+ } | |
} | |
} | |
diff --git a/js/tygh/responsive.js b/js/tygh/responsive.js | |
index f9762c8103..8336fe195e 100644 | |
--- a/js/tygh/responsive.js | |
+++ b/js/tygh/responsive.js | |
@@ -9,12 +9,15 @@ | |
}, | |
responsiveScroll: function() { | |
- $.ceEvent('on', 'ce.needScroll', function(opt) { | |
+ this.needScrollInited = this.needScrollInited || false; | |
+ | |
+ if (this.needScrollInited) { | |
+ return; | |
+ } | |
+ this.needScrollInited = true; | |
- opt.need_scroll = false; | |
- setTimeout(function() { | |
- $.scrollToElm(opt.jelm.data('caScroll')); | |
- }, 310); | |
+ $.ceEvent('on', 'ce.needScroll', function(opt) { | |
+ opt.timeout = 310; | |
}); | |
}, | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment