You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment we are changing the URL params as the selection changes – not sure if this may cause issues on slower devices. An alternative is https://jsfiddle.net/dimshik/z8Jge/
var selectionEndTimeout = null;
// bind selection change event to my function
document.onselectionchange = userSelectionChanged;
function userSelectionChanged() {
// wait 500 ms after the last selection change event
if (selectionEndTimeout) {
clearTimeout(selectionEndTimeout);
$('.log ol').append('<li>User Selection Changed</li>');
// scroll to bottom of the div
$('.log').scrollTop($('.log ol').height());
}
selectionEndTimeout = setTimeout(function () {
$(window).trigger('selectionEnd');
}, 500);
}
// helper function
function getSelectionText() {
var text = "";
if (window.getSelection) {
text = window.getSelection().toString();
} else if (document.selection && document.selection.type != "Control") {
text = document.selection.createRange().text;
}
return text;
}
$(window).bind('selectionEnd', function () {
// reset selection timeout
selectionEndTimeout = null;
// TODO: Do your cool stuff here........
$('.log ol').append('<li>User Selection Ended</li>');
// scroll to bottom of the div
$('.log').scrollTop($('.log ol').height());
// get user selection
var selectedText = getSelectionText();
// if the selection is not empty show it :)
if(selectedText != ''){
$('.selected-text ol').append('<li>' + selectedText + '</li>');
// scroll to bottom of the div
$('.selected-text').scrollTop($('.selected-text ol').height());
}
});
The text was updated successfully, but these errors were encountered:
At the moment we are changing the URL params as the selection changes – not sure if this may cause issues on slower devices. An alternative is https://jsfiddle.net/dimshik/z8Jge/
The text was updated successfully, but these errors were encountered: