Medium Style Text Selection Sharing Library – share-this

Category: Javascript , Recommended , Social Media | October 5, 2018
Author: MaxArt2501
Views Total: 2,033
Official Page: Go to website
Last Update: October 5, 2018
License: MIT

Preview:

Medium Style Text Selection Sharing Library – share-this

Description:

share-this is a JavaScript library for creating a Medium-style floating panel to share the text selections on social networks (Facebook, Twitter, Linkedin, Reddit and Email).

Installation:

# Yarn
$ yarn add share-this

# NPM
$ npm install share-this --save

How to use it:

Include the share-this’ stylesheet in the head section of the html document.

<link href="dist/share-this.css" rel="stylesheet" type="text/css">

Include the main JavaScript file ‘share-this.js’ and social networks of your choice at the end of the document.

<script src="dist/share-this.js"></script>
<script src="dist/sharers/email.js"></script>
<script src="dist/sharers/facebook.js"></script>
<script src="dist/sharers/linked-in.js"></script>
<script src="dist/sharers/reddit.js"></script>
<script src="dist/sharers/twitter.js"></script>

Initialize the share-this as follow:

ShareThis({
  sharers: [ ShareThisViaTwitter, ShareThisViaFacebook, ShareThisViaReddit, ShareThisViaLinkedIn, ShareThisViaEmail ],
  selector: "article"
}).init();

All possible options with default values.

ShareThis({
  document: document,
  popoverClass: 'share-this-popover',
  selector: 'body',
  shareUrl: document.body,
  transformer: raw => raw.trim().replace(/\s+/g, " ")
})

Callback functions available.

ShareThis({
  onOpen: function(){},
  onClose: function(){}
})

Changelog:

10/05/2018

  • v1.2.2

You Might Be Interested In:


Leave a Reply