fix tour: fix event listeners not working properly

This commit is contained in:
Mahdi Dibaiee 2015-09-06 17:38:25 +04:30
parent 5b41b8d6dc
commit 2929dedb6a
3 changed files with 16 additions and 10 deletions

View File

@ -23,7 +23,7 @@ Please read the Features section below and issues to make sure your issue is not
- [x] Filter Files
- [x] Swipe Gestures (Up directory by swiping right)
- [x] Search
- [x] Intro
- [x] First-run Tour
- [ ] Different views (List, Icons, etc)
- [ ] Share Files
- [ ] Preferences

View File

@ -32355,16 +32355,18 @@ exports['default'] = function () {
var _loop = function () {
var item = _step.value;
item.addEventListener('touchstart', function listener(e) {
var firstClass = item.className.slice(0, item.className.indexOf(' '));
var ev = firstClass === 'drawer' ? 'touchstart' : 'click';
item.addEventListener(ev, function listener(e) {
e.preventDefault();
e.stopPropagation();
clearTimeout(timeout);
listeners.push({ item: item, listener: listener });
listeners.push({ item: item, listener: listener, ev: ev });
shown++;
var firstClass = item.className.slice(0, item.className.indexOf(' '));
tour.innerHTML = MESSAGES[firstClass];
timeout = setTimeout(function () {
@ -32381,9 +32383,10 @@ exports['default'] = function () {
var _step2$value = _step2.value;
var _item = _step2$value.item;
var _listener = _step2$value.listener;
var _ev = _step2$value.ev;
console.log(_item, _listener);
_item.removeEventListener('touchstart', _listener);
_item.removeEventListener(_ev, _listener);
}
} catch (err) {
_didIteratorError2 = true;

View File

@ -27,16 +27,19 @@ export default function() {
let listeners = [];
for (let item of items) {
item.addEventListener('touchstart', function listener(e) {
let firstClass = item.className.slice(0, item.className.indexOf(' '));
let ev = firstClass === 'drawer' ? 'touchstart' : 'click';
item.addEventListener(ev, function listener(e) {
e.preventDefault();
e.stopPropagation();
clearTimeout(timeout);
listeners.push({item, listener});
listeners.push({item, listener, ev});
shown++;
let firstClass = item.className.slice(0, item.className.indexOf(' '));
tour.innerHTML = MESSAGES[firstClass];
timeout = setTimeout(() => {
@ -44,9 +47,9 @@ export default function() {
wrapper.classList.remove('tour');
localStorage.setItem('tourRan', 'true');
for (let {item, listener} of listeners) {
for (let {item, listener, ev} of listeners) {
console.log(item, listener);
item.removeEventListener('touchstart', listener);
item.removeEventListener(ev, listener);
}
}
}, DIALOG_HIDE_DELAY);