How to use drag-drop - 7 common examples

To help you get started, we’ve selected a few drag-drop examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googlecreativelab / creatability-seeing-music / src / interface / FileDrop.js View on Github external
constructor(returnType='url'){
		super()

		this.returnType = returnType

		this.element = document.body.querySelector('#file-drop')
		this.button = this.element.querySelector('#uploadButton')
		this.status = this.element.querySelector('#uploadedFile')
		/**
		 * DRAG DROP HANDLING
		 */
		dragDrop('body', (files) => {
			const file = files[0]
			this._getFile(file)
			
		})

		/**
		 * FILE UPLOAD BUTTON CLICK
		 */
		this.fileDialog = this.element.querySelector('.file-input')
		this.fileDialog.addEventListener('change', e => {
			// console.log(e)
			if (e.target.files && e.target.files[0]){
				this._getFile(e.target.files[0])
			}
		})
github beakerbrowser / beaker / app / builtin-pages / views / library-view.js View on Github external
async function setup () {
  // setup dragdrop
  dragDrop(document.body, onDropFiles)

  try {
    // load platform info
    let browserInfo = beaker.browser.getInfo()
    window.OS_CAN_IMPORT_FOLDERS_AND_FILES = browserInfo.platform === 'darwin'
    osUsesMetaKey = browserInfo.platform === 'darwin'

    // load data
    let url = await parseLibraryUrl()
    archive = new LibraryDatArchive(url)
    await archive.setup()
    await setupWorkingCheckout()

    // go to raw key if we have a shortname
    // (archive.info.url is always the raw url, while archive.url will reflect the given url)
    if (archive.url.startsWith(archive.info.url) === false) {
github baku89 / feedback-displacement / src / commands.js View on Github external
_initDragDrop() {

		dragDrop('body', (files) => this._validateImageAndEmit('load-source', files))
	}
github machawk1 / wail / wail-ui / components / wayback / collectionView / collectionView.js View on Github external
componentDidMount () {
    if (!this.removeWarcAdder) {
      console.log('attaching warc adder on live dom')
      this.removeWarcAdder = BeamMeUpScotty('#warcUpload', (files) => {
        console.log(`adding warcs maybe to col ${this.props.params.col}`, files)
        let addMe = []
        let badFiles = new Set()

        files.forEach(f => {
          console.log(f)
          let ext = path.extname(f.path)
          if (ext === '.warc' || ext === '.arc') {
            addMe.push(f.path)
          } else {
            badFiles.add(ext)
          }
        })

        if (badFiles.size > 0) {
          notify.notifyWarning(`Unable to add files with extensions of ${joinStrings(...badFiles, { separator: ',' })}`)
github digidem / react-mapfilter / src / components / upload_form_data_modal.js View on Github external
componentDidMount () {
    this.resetUploader()

    this.removeDragDrop = dragDrop(findDOMNode(this.uploadContainer), files => {
      this.uploader.add(files, err => {
        if (err) {
          console.warn(err.stack)
        }
      })
    })
  }
github machawk1 / wail / wail-ui / components / collections / addToCollection / fromFs / addFromFs.js View on Github external
componentDidMount () {
    if (!this.removeWarcAdder) {
      this.removeWarcAdder = BeamMeUpScotty('#warcUpload', this.fileListener)
    }
  }
github transloadit / uppy / src / plugins / Modal / _dashboard.js View on Github external
install () {
    const target = this.opts.target
    const plugin = this
    this.target = this.mount(target, plugin)

    dragDrop(`${this.target} .UppyDashboard`, (files) => {
      this.handleDrop(files)
      this.core.log(files)
    })
  }
}

drag-drop

HTML5 drag & drop for humans

MIT
Latest version published 3 years ago

Package Health Score

59 / 100
Full package analysis

Popular drag-drop functions