Add Draggable QR Image In the Chrome Extension

in #utopian-io9 years ago

Github: https://github.com/DoctorLai/simple-qr-code
Commit: https://github.com/DoctorLai/simple-qr-code/commit/d146ba6f92602af6659a2a20453f3a820592fa11#diff-84c8cc9cb7404cad0e73f3490195d979
Chrome WebStore: https://chrome.google.com/webstore/detail/offline-qr-code-generator/kfhbhjigpkcbpmknfomdobahejfajado

I have spent some time today adding the Draggable QR Image in the Chrome Extension Offline QR Code Generator/Editor

So you can right click on any page (optionally selecting any text)
image.png

and drag the QR everywhere! and you can double click the edit the QR text on the fly.

image.png

This change:

https://github.com/DoctorLai/simple-qr-code/blob/master/simple-qr-code/js/contentscript.js

function dragElement(elmnt) {
      var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
      if (document.getElementById(elmnt.id + "header")) {
        /* if present, the header is where you move the DIV from:*/
        document.getElementById(elmnt.id + "header").onmousedown = dragMouseDown;
      } else {
        /* otherwise, move the DIV from anywhere inside the DIV:*/
        elmnt.onmousedown = dragMouseDown;
      }

      function dragMouseDown(e) {
        e = e || window.event;
        // get the mouse cursor position at startup:
        pos3 = e.clientX;
        pos4 = e.clientY;
        document.onmouseup = closeDragElement;
        // call a function whenever the cursor moves:
        document.onmousemove = elementDrag;
      }

      function elementDrag(e) {
        e = e || window.event;
        // calculate the new cursor position:
        pos1 = pos3 - e.clientX;
        pos2 = pos4 - e.clientY;
        pos3 = e.clientX;
        pos4 = e.clientY;
        // set the element's new position:
        elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
        elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
      }

      function closeDragElement() {
        /* stop moving when mouse button is released:*/
        document.onmouseup = null;
        document.onmousemove = null;
      }
    }

    dragElement(document.getElementById("weibomiaopaiqrcode"));

Proof of Work

doctorlai is my github ID and you can see on my profile page that it has my SteemID URL written.



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Good to know! Thanks for sharing this!

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]


You can consider change raw links with the text for initial links.

Hey @justyy I am @utopian-io. I have just upvoted you!

Achievements

  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.04
TRX 0.33
JST 0.099
BTC 62746.00
ETH 1776.56
USDT 1.00
SBD 0.38