Giter Site home page Giter Site logo

Comments (5)

beefchimi avatar beefchimi commented on May 13, 2024 2

I am hoping to get some examples in by the time we do our first stable release. Apologies for the delay! Code is pretty straight forward - here is an example of the Collidable section:

import {Droppable, Collidable} from 'draggable';
import SoundFx from '../../SoundFx';

export default function CollidableSection() {
  const containers = document.querySelectorAll('.CubesFrame--idCollidable');

  const droppable = new Droppable(containers, {
    draggable: '.draggable-source',
    droppable: '.Cube--typeDroppable',
    appendTo: '.CubesFrame--idCollidable',
    collidables: '.CubesFrame--idCollidable .CollisionWall',
    classes: {
      body: 'draggable-container--is-dragging',
    },
    plugins: [Collidable],
  });

  // --- Drag states --- //
  let canPlayOverSound = false;

  droppable.on('drag:start', () => {
    SoundFx.Single.play('cubeUp');
  });

  droppable.on('drag:over', () => {
    if (!canPlayOverSound) {
      return;
    }

    SoundFx.Single.play('cubeOver');
  });

  droppable.on('drag:out', () => {
    canPlayOverSound = true;
  });

  droppable.on('drag:stop', () => {
    SoundFx.Single.play('cubeDown');
    canPlayOverSound = false;
  });

  droppable.on('collidable:in', ({collidingElement}) => {
    SoundFx.Single.play('cubeCollide');
    collidingElement.classList.add('isColliding');
  });

  droppable.on('collidable:out', ({collidingElement}) => {
    collidingElement.classList.remove('isColliding');
  });

  return droppable;
}

from draggable.

fredbenenson avatar fredbenenson commented on May 13, 2024 1

Sweet! Go @tsov :) I decided to switch to jQuery.draggable() for the time being since it just worked out of the box – but I'd much prefer to use Draggable since it's clear you guys put some great thought and work into it – particularly the touch support. Regardless thanks for your hard work!

from draggable.

fredbenenson avatar fredbenenson commented on May 13, 2024

Just seconding this – would love an un-minified version of the gh-pages javascript! Thanks for a great library.

from draggable.

beefchimi avatar beefchimi commented on May 13, 2024

Getting very close to finishing our Examples site - which will be open sourced in this repo. Just need @tsov to finish up some things on Draggable so we can do a full release.

Apologies for the delay everyone!

from draggable.

beefchimi avatar beefchimi commented on May 13, 2024

Closed by #118

from draggable.

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.