Socket
Socket
Sign inDemoInstall

svg-deep-link

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    svg-deep-link

Vanilla javascript and Web Component wrapper to make any svg zoom pan and deep link


Version published
Maintainers
1
Created

Readme

Source

deep-svg

Vanilla javascript and Web Component wrapper, using no dependencies for an svg pan zoom and deep linking. Interactions for making every text clickable and highlatable. Deep Linking allows links winthin html pages, why not generalise this to the text inside svg and without having to edit the svg ? Each tspan is enriched with a click event, and the highlight function uses an animated svg filter.

Live Demo

https://networkgraphs.github.io/deep-svg/

Gif Demo

Usage

as a vanilla javascript module

import * as svgm from "../src/index.js";

let svg = await svgm.createElement(document.body,{src:"/demo/diagram.svg",id:"diagram_a",enable:true});
svg.addEventListener('text_click',onTextClick);
svgm.highlightText(svg,"Rollup");

as a web component

Note that html() is a 3 line helper function and /*html*/ helps lint the html text with the 'es6-string-html' plugin

import "../src/deep_svg.js";

const src = "/demo/diagram.svg"
const deep = html(document.body,/*html*/`<deep-svg id="id1" src=${src} enable="true" />`);
deep.addEventListener('text_click',onTextClick);
deep.highlightText("Rollup");

SVG Filter Animation

The highlight is animated through a morphology filter to create a smooth effect. The dialate operator radius is animated before the Gaussian blur is applied to it.

Caution : This is vanilla javascript. Note that the function anim_wave() is a generic function that can be placed in any section and starts animating the passed attribute patemeter.

References

Keywords

FAQs

Last updated on 12 Mar 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc