Skip to content

Instantly share code, notes, and snippets.

View petermeissner's full-sized avatar
💻
githubbing

Peter Meissner petermeissner

💻
githubbing
View GitHub Profile
@petermeissner
petermeissner / README.md
Last active May 23, 2020 18:46 — forked from thudfactor/README.md
Drag from HTML, Drop to SVG

This demonstrates dragging from HTML to SVG elements, which can be tricky because of the differences between SVG and HTML DOMs. JQueryUI has a nice API for handling drag and drop, including defining the appearance of a dragged object and providing start, drag, and stop events. Unfortunately, JQueryUI's "drop" does not work at all on SVG elements inside the SVG tag, although it does appear to work on the SVG tag itself.

To get over this limitation, we create a custom Drag/Drop manager, and use the start, drag, and stop events for the dragged elements in conjunction with mouseover and mouseout events on the SVG elements to determine whether or not a "drop" has been dropped on a legal SVG element.

#!/path/2/Rscript
# License: CC0 (just be nice and point others to where you got this) Author:
# Robert M Flight <rflight79@gmail.com>, github.com/rmflight
#
# This is a post-commit hook that after a successful commit subsequently
# increments the package version in DESCRIPTION and commits that. Analogous to
# the pre-commit at https://gist.github.com/rmflight/8863882, but useful if you
# only have good reasons for not doing it on the pre-commit.
#