From d7941ef087e4ca0c114aebfeef49ace30eb82bfc Mon Sep 17 00:00:00 2001 From: TMSBK Date: Tue, 22 Jan 2019 16:23:02 +0100 Subject: [PATCH 1/4] Waypoint triggered by comment-section. Now triggered by social-comment. --- .../ui_3/views/components/comments-section.js | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/imports/ui_3/views/components/comments-section.js b/imports/ui_3/views/components/comments-section.js index 363964cd5..a17ca45e6 100644 --- a/imports/ui_3/views/components/comments-section.js +++ b/imports/ui_3/views/components/comments-section.js @@ -21,15 +21,18 @@ Template.Comments_section.onCreated(function commentsSectionOnCreated() { }); Template.Comments_section.onRendered(function chatboxOnRendered() { - this.waypoint = new Waypoint({ - element: this.find('.comment-section'), - handler() { - const topicId = this.element.dataset.id; - // displayMessage('info', `You just seen ${topicId}`); // debug - Meteor.user().hasNowSeen(topicId); - }, - offset: '80%', - }); + const comments = $('.social-comment'); + const topicId = this.data._id; + for (let i = 0; i < comments.length; i += 1) { + this.waypoint = new Waypoint({ + element: comments[i], + handler: () => { + Meteor.user().hasNowSeen(topicId); + }, + continuous: false, + offset: '85%', + }); + } // Above is nicer syntax , but requires bigu:jquery-waypoints https://stackoverflow.com/questions/28975693/using-jquery-waypoints-in-meteor /* this.waypoint = this.$('.comment-section').waypoint(function (direction) { displayMessage('info', `You just seen ${this.dataset.id}`); // debug From c1dbc61ec3af365bb4718eca7efaab24e6808f96 Mon Sep 17 00:00:00 2001 From: TMSBK Date: Tue, 22 Jan 2019 18:03:12 +0100 Subject: [PATCH 2/4] Fixed selecting elements --- imports/ui_3/views/components/comments-section.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imports/ui_3/views/components/comments-section.js b/imports/ui_3/views/components/comments-section.js index a17ca45e6..832dc28ed 100644 --- a/imports/ui_3/views/components/comments-section.js +++ b/imports/ui_3/views/components/comments-section.js @@ -21,12 +21,12 @@ Template.Comments_section.onCreated(function commentsSectionOnCreated() { }); Template.Comments_section.onRendered(function chatboxOnRendered() { - const comments = $('.social-comment'); - const topicId = this.data._id; + const comments = this.findAll('.social-comment'); for (let i = 0; i < comments.length; i += 1) { this.waypoint = new Waypoint({ element: comments[i], handler: () => { + const topicId = this.data._id; Meteor.user().hasNowSeen(topicId); }, continuous: false, From 9ab42a1ea029a5825bbe4a64decdc823ecc40de9 Mon Sep 17 00:00:00 2001 From: TMSBK Date: Wed, 23 Jan 2019 19:41:31 +0100 Subject: [PATCH 3/4] Waypoint triggers to comment-section bottom, and refresh all waypoints. --- .../ui_3/views/components/comments-section.js | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/imports/ui_3/views/components/comments-section.js b/imports/ui_3/views/components/comments-section.js index 832dc28ed..cdab6ed15 100644 --- a/imports/ui_3/views/components/comments-section.js +++ b/imports/ui_3/views/components/comments-section.js @@ -21,18 +21,15 @@ Template.Comments_section.onCreated(function commentsSectionOnCreated() { }); Template.Comments_section.onRendered(function chatboxOnRendered() { - const comments = this.findAll('.social-comment'); - for (let i = 0; i < comments.length; i += 1) { - this.waypoint = new Waypoint({ - element: comments[i], - handler: () => { - const topicId = this.data._id; - Meteor.user().hasNowSeen(topicId); - }, - continuous: false, - offset: '85%', - }); - } + this.waypoint = new Waypoint({ + element: this.find('.comment-section'), + handler() { + const topicId = this.element.dataset.id; + // displayMessage('info', `You just seen ${topicId}`); // debug + Meteor.user().hasNowSeen(topicId); + }, + offset: 'bottom-in-view', + }); // Above is nicer syntax , but requires bigu:jquery-waypoints https://stackoverflow.com/questions/28975693/using-jquery-waypoints-in-meteor /* this.waypoint = this.$('.comment-section').waypoint(function (direction) { displayMessage('info', `You just seen ${this.dataset.id}`); // debug @@ -41,6 +38,14 @@ Template.Comments_section.onRendered(function chatboxOnRendered() { });*/ }); +Template.Comment.onRendered(function () { + Waypoint.refreshAll(); +}); + +Template.Comment.onDestroyed(function () { + Waypoint.refreshAll(); +}); + Template.Comments_section.onDestroyed(function chatboxOnDestroyed() { this.waypoint.destroy(); }); From c74c68d5e42b2f1dbd5876c78ee228252a61bae0 Mon Sep 17 00:00:00 2001 From: TMSBK Date: Thu, 24 Jan 2019 11:43:37 +0100 Subject: [PATCH 4/4] Code positioning --- .../ui_3/views/components/comments-section.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/imports/ui_3/views/components/comments-section.js b/imports/ui_3/views/components/comments-section.js index cdab6ed15..7ae3d4291 100644 --- a/imports/ui_3/views/components/comments-section.js +++ b/imports/ui_3/views/components/comments-section.js @@ -38,14 +38,6 @@ Template.Comments_section.onRendered(function chatboxOnRendered() { });*/ }); -Template.Comment.onRendered(function () { - Waypoint.refreshAll(); -}); - -Template.Comment.onDestroyed(function () { - Waypoint.refreshAll(); -}); - Template.Comments_section.onDestroyed(function chatboxOnDestroyed() { this.waypoint.destroy(); }); @@ -79,6 +71,14 @@ Template.Comments_section.events({ const MAX_LENGTH = 400; +Template.Comment.onRendered(function () { + Waypoint.refreshAll(); +}); + +Template.Comment.onDestroyed(function () { + Waypoint.refreshAll(); +}); + Template.Comment.helpers({ textTooLong() { return this.text.length > MAX_LENGTH;