Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a hover-pause to the waterfall and moderation UI #249

Merged
merged 2 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/TagzApp.Web/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"Description": "YouTube is a free video sharing website that makes it easy to watch online videos. You can even create and upload your own videos to share with others."
},
"twitchchat": {
"ChannelName": "csharpfritz"
"ChannelName": "csharpfritz",
"Activated": true
},
"twitter": {
"Activated": false,
Expand Down
49 changes: 46 additions & 3 deletions src/TagzApp.Web/wwwroot/js/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
};

var paused = false;
var rolloverPause = false;
var pauseQueue = [];
var pauseTimeout;
const waterfallMaxEntries = 100;
const moderationMaxEntries = 500;

Expand Down Expand Up @@ -351,10 +353,40 @@
}
}

function PauseOnRollover(ev) {
// pause updates
window.clearTimeout(pauseTimeout);
if (!paused) {
paused = true;
rolloverPause = true;
FormatPauseButton();
}

ev.srcElement.addEventListener('mouseleave', function (ev) {
// resume updates if we mouse out
if (rolloverPause) {
pauseTimeout = window.setTimeout(() => {
paused = false;
rolloverPause = false;
FormatPauseButton();
ResumeFromPause();
}, 1500);
}
});
}

function showModerationPanel(ev) {
var hovered = ev.target.closest('article');
if (hovered.querySelector('#moderationAction')) return;

// pause updates
window.clearTimeout(pauseTimeout);
if (!paused) {
paused = true;
rolloverPause = true;
FormatPauseButton();
}

var hoverPanel = document
.getElementById('moderationAction')
.cloneNode(true);
Expand Down Expand Up @@ -392,6 +424,17 @@
hovered.insertBefore(hoverPanel, hovered.firstElementChild);

hoverPanel.addEventListener('mouseleave', function (ev) {
// resume updates if we mouse out
if (rolloverPause) {
pauseTimeout = window.setTimeout(() => {
paused = false;
rolloverPause = false;
FormatPauseButton();
ResumeFromPause();
}, 1500);
}

// cleanup the moderation overlay
ev.target.closest('#moderationAction').remove();
var panels = document.querySelectorAll('.active_panel');
panels.forEach(function (panel) {
Expand Down Expand Up @@ -470,7 +513,7 @@
if (document.querySelector('.currentModerators')) {
FormatMessageForModeration(content);
} else {
FormatMessage(content);
FormatMessage(content, null, null, PauseOnRollover);
}
});

Expand Down Expand Up @@ -499,7 +542,7 @@
AddMessageToPauseQueue(content);
return;
}
FormatMessage(content);
FormatMessage(content, null, null, PauseOnRollover);
});

connection.on('RemoveMessage', (provider, providerId) => {
Expand All @@ -521,7 +564,7 @@
.invoke('GetExistingContentForTag', tags)
.then(function (result) {
result.forEach(function (content) {
FormatMessage(content);
FormatMessage(content, null, null, PauseOnRollover);
});
window.Masonry.resizeAllGridItems();
});
Expand Down