GithubHelp home page GithubHelp logo

dlavineway / electron-drag-drop Goto Github PK

View Code? Open in Web Editor NEW

This project forked from electron-utils/electron-drag-drop

0.0 1.0 0.0 38 KB

Easily manipulate drag and drop in Electron

License: MIT License

JavaScript 100.00%

electron-drag-drop's Introduction

electron-drag-drop

Linux Build Status Windows Build status Dependency Status devDependency Status

Easily manipulate drag and drop in Electron.

Install

npm install --save electron-drag-drop

Run Examples:

npm start example

Usage

main process

// IMPORTANT: electron-drag-drop needs init in main process for broadcasting ipc messages.
// init drag-drop in main process
require('electron-drag-drop');

renderer process

<body>
  <div id="drag" draggable="true">Draggable Item</div>
  <div id="drop" droppable="foobar" multi >Droppable Area</div>

  <script>
    const {drag, droppable, addon} = require('electron-drag-drop');

    // drag
    let dragEL = document.getElementById('drag');

    dragEL.addEventListener('dragstart', event => {
      drag.start(event.dataTransfer, {
        effect: 'copy',
        type: 'foobar',
        items: 'Hello World!',
      });
    });
    dragEL.addEventListener('dragend', event => {
      drag.end();
    });

    // drop
    let dropEL = document.getElementById('drop');

    addon(dropEL, droppable);
    dropEL._initDroppable(dropEL);
    dropEL.addEventListener('drop-area-move', event => {
      drag.updateDropEffect(event.detail.dataTransfer, 'copy');
    });
  </script>
</body>

API Reference

License

MIT © 2017 Johnny Wu

electron-drag-drop's People

Contributors

jwu avatar visualsj avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.