All Projects → callmecavs → heading-links.js

callmecavs / heading-links.js

Licence: other
A small, dependency-free library for deep linking headings - GitHub style.

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Labels

Projects that are alternatives of or similar to heading-links.js

Linkt
A lightweight and simple Kotlin library for deep link handling on Android 🔗.
Stars: ✭ 101 (+53.03%)
Mutual labels:  deeplink
html-page-call-native
❤️ HTML5 call native app
Stars: ✭ 33 (-50%)
Mutual labels:  deeplink
deep-link
🌈 Redirecting iOS/Android App from your Web
Stars: ✭ 17 (-74.24%)
Mutual labels:  deeplink
ionic-socialsharing-with-deeplinking-example
Ionic Social Sharing and Deep Linking example app. Complete Ionic Tutorial with free example app! Built for Ionic 3.
Stars: ✭ 16 (-75.76%)
Mutual labels:  deeplink
Urlnavigator
⛵️ Elegant URL Routing for Swift
Stars: ✭ 2,760 (+4081.82%)
Mutual labels:  deeplink
Jlroutes
URL routing library for iOS with a simple block-based API
Stars: ✭ 5,528 (+8275.76%)
Mutual labels:  deeplink
kotlin-simple-architecture
Kotlin Simple Architecture
Stars: ✭ 35 (-46.97%)
Mutual labels:  deeplink

heading-links.js

Inspiration: https://twitter.com/_dte/status/580873945580109824

A small (< 2kb minified), dependency-free library for deep linking headings - GitHub style. It does so by taking a headings text content, parsing it into URL format, adding an ID attribute, and inserting a link that appears on hover.

Demo

Download the repo, unzip it, and check out demo.html.

Usage

Load the stylesheet.

<!-- only if hover links are enabled -->

<link rel="stylesheet" href="heading-links.min.css">

Load the script.

<script src="heading-links.min.js"></script>

Create a new instance with your desired options. Defaults shown below.

var headingLinks = new HeadingLinks({
  // options here, defaults shown below

  selector: 'h1, h2, h3',
  hoverLinks: true,
  hoverHeadingAttr: 'data-heading',
  hoverLinkAttr: 'data-heading-link'
});

API

HeadingLinks(options)

Create a new instance of HeadingLinks.

var headingLinks = new HeadingLinks({
  // options here
});

.create()

Adds ID attribute to headings, based on the selector.

headingLinks.create();

This method is called automatically when creating a new instance.

.destroy()

Removes ID attribute from headings, based on the selector.

headingLinks.destroy();

.addHoverLinks()

Inserts hover links into headings, based on the selector.

headingLinks.addHoverLinks();

This method is called automatically when creating a new instance if hover links are enabled.

.removeHoverLinks()

Removes hover links from headings, based on the selector.

headingLinks.removeHoverLinks();

.getList()

Returns a NodeList of all headings matched by the selector for this instance.

var listOfHeadings = headingLinks.getList();

License

MIT. © Michael Cavalea.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].