GithubHelp home page GithubHelp logo

Comments (4)

jshor avatar jshor commented on August 20, 2024 6

I used vue-cli to bootstrap a project with draw2d in it. You need to have jQuery exposed on the window object in your webpack config, and import the jQuery UI droppable plugin.

yarn add jquery jquery-ui draw2d

in vue.config.js (or webpack directly), expose jQuery to the window:

const webpack = require('webpack')

module.exports = {
  configureWebpack: {
    plugins: [
      new webpack.ProvidePlugin({
        '$': 'jquery',
        'jquery': 'jquery',
        'window.jQuery': 'jquery',
        'jQuery': 'jquery'
      })
    ],
  }
}

in main.js (or whatever endpoint you initialize vue in), import jquery-ui droppable:

import 'jquery-ui/ui/widgets/draggable'
import 'jquery-ui/ui/widgets/droppable'

unfortunately the instantiation of draw2d requires that the droppable plugin is defined, so if you don't plan on using the drag-and-drop feature to create new elements in draw2d, you can just turn them off instead of using/importing jQuery UI:

import $ from 'jquery'

$.fn.draggable = () => {}
$.fn.droppable = () => {}

then you should be able to use draw2d in your vue app like so:

<template>
  <div id="draw2d" />
</template>

<script>
import draw2d from 'draw2d'

export default {
  name: 'Draw2D',
  mounted () {
    const canvas = new draw2d.Canvas('draw2d')
  }
}
</script>

from draw2d.

jshor avatar jshor commented on August 20, 2024 1

Hi @Samanoova - I didn't notice any performance hits with this solution, but I haven't tested it extensively

from draw2d.

roblambertini avatar roblambertini commented on August 20, 2024

@jshor Thank you very much, it works!

from draw2d.

Samanoova avatar Samanoova commented on August 20, 2024

Hi @jshor
thank you for the solution I would ask you!
did you face any problem with performance after this solution?

from draw2d.

Related Issues (20)

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.