src/Sortable/Sortable.js
function onSortableSortedDefaultAnnouncement({dragEvent}) {
  const sourceText = dragEvent.source.textContent.trim() || dragEvent.source.id || 'sortable element';

  if (dragEvent.over) {
    const overText = dragEvent.over.textContent.trim() || dragEvent.over.id || 'sortable element';
    const isFollowing = dragEvent.source.compareDocumentPosition(dragEvent.over) & Node.DOCUMENT_POSITION_FOLLOWING;

    if (isFollowing) {
      return `Placed ${sourceText} after ${overText}`;
    } else {
      return `Placed ${sourceText} before ${overText}`;
    }
  } else {
    // need to figure out how to compute container name
    return `Placed ${sourceText} into a different container`;
  }
}
function onSortableSortedDefaultAnnouncement({dragEvent}) {
  const sourceText = dragEvent.source.textContent.trim() || dragEvent.source.id || 'sortable element';

  if (dragEvent.over) {
    const overText = dragEvent.over.textContent.trim() || dragEvent.over.id || 'sortable element';
    const isFollowing = dragEvent.source.compareDocumentPosition(dragEvent.over) & Node.DOCUMENT_POSITION_FOLLOWING;

    if (isFollowing) {
      return `Placed ${sourceText} after ${overText}`;
    } else {
      return `Placed ${sourceText} before ${overText}`;
    }
  } else {
    // need to figure out how to compute container name
    return `Placed ${sourceText} into a different container`;
  }
}
function onSortableSortedDefaultAnnouncement ( { dragEvent } ) { const sourceText = dragEvent . source . textContent . trim ( ) || dragEvent . source . id || 'sortable element' ; if ( dragEvent . over ) { const overText = dragEvent . over . textContent . trim ( ) || dragEvent . over . id || 'sortable element' ; const isFollowing = dragEvent . source . compareDocumentPosition ( dragEvent . over ) & Node . DOCUMENT_POSITION_FOLLOWING ; if ( isFollowing ) { return ` ${ sourceText } ${ overText } ` ; } else { return ` ${ sourceText } ${ overText } ` ; } } else { // need to figure out how to compute container name return ` ${ sourceText } ` ; } }
Returns announcement message when a Draggable element has been sorted with another Draggable element
or moved into a new container
@param {SortableSortedEvent} sortableEvent
@return {String}
Returns announcement message when a Draggable element has been sorted with another Draggable element or moved into a new container