Git Product home page Git Product logo

canvas-experiments's Introduction

canvas-experiments

Experimenting with a HTML5 canvas to create a drag-and-drop style interface

canvas-experiments's People

Contributors

davethw avatar

Stargazers

 avatar gis4ll avatar

Watchers

James Cloos avatar  avatar

canvas-experiments's Issues

Standardise parameters for Group.draw() and Shape.draw()

Currently, Group.draw() and Shape.draw() take different arguments - ideally I think we should match these up, as then we needn't have differing calls to draw() depending on various conditions...

Maybe use .draw(active, drawingContext, colour, line_colour)..? And let Shape.draw() decide how to show active / non-active shapes? - how do we best standardise the transparency/grey-ness across different shapes..? - maybe add a inactive() method to Colour?..

When grouping items, insert the new sub-group at some relevant position within the parent group

This is sort of the opposite of Issue #13, although a little more complicated. Needs ability to insert items at a given point in a group (related to Issue #9).
Need to decide where to insert the new sub-group if the selected items are scattered through the parent group... Choices are probably:

  • front-most position of selected items
  • back-most position of selected items
  • half way between the front-most and back-most positions
  • average (mean?) of all the item's positions
  • position of the 'middle' item within the selection
    • for an even number of items, go for the front-middle item
  • identify the largest contiguous section of selected items within the parent group
    • when there are multiple sections of the same size, go for the (front-)middle section

For a group of ten items, with 3 selected, these might produce the following results:

1
2 Selected - Back-most
3 Selected - 'Middle' item + Largest contiguous selection
4
5 'Average' position
6 'Half-way' position
7
8
9
10 Selected - Front-most

I think I currently favour Largest contiguous selection... Second choice is probably 'Middle' item (with a bias towards 'front-middle' if there an even number of items selected), and third choice is probably Front-most.

Maybe (eventually) offer this as an option to the user..? Either a global option, or a pop-up option when grouping items (if different algorithms give different results...)..?? (pop-up option might get really annoying!..)

Work on maxX, maxY, etc for groups

Currently a group doesn't really have a maxX, maxY, etc. This means that a group containing a group doesn't draw it's selected box correctly!..

Add more properties to Item

Add things like 'delete()' (which can just call parent.delete(this)) and 'select()' (which can call parent.selection.add(this))... Could make code elsewhere much more legible!

It might also be neat to change 'parent' and 'index' into getter/setter values, with the setter function calling the appropriate functions to make the change...

Check that code remains 'internal' to all objects

For example, until recently Group.moveAndResetDragOffset would directly change Shape.x, Shape.y and Shape.dragOffset - I think it's better to call a function within Shape.prototype (or a more specific version from Circle) to make these changes. This keeps code related to modifying Shapes within Shape, etc...

Cancelling a drag can produce odd effects with a group

Mouse.prototype.cancelDrag() contains a loop to (try to) reset all the selected objects' offsets to mouse.dragNoOffset - but the loop doesn't iterate down through any groups. So the group itself gains an offset property, and the child elements remain with their offset properties linked to mouse.dragOffset - therefore if you subsequently drag another item, the group moves with it! And then, even weirder, pings back to where it was when you finish the drag (when mouse.dragOffset gets reset to null values)!!

Instead of this (faulty) loop, Mouse.prototype.cancelDrag() should just call current_stack.selection.setOffset(this.dragNoOffset)...

Looks like ungroup might also ungroup any child groups...

ie. if we have

  1. Circle (1)
  2. Group (2)
    1. Circle (3)
    2. Group (4)
      1. Circle (5)
      2. Circle (6)
    3. Circle (7)
  3. Circle (8)

Then ungrouping Group (2) should leave us with this:

  1. Circle (1)
  2. Circle (3)
  3. Group (4)
    1. Circle (5)
    2. Circle (6)
  4. Circle (7)
  5. Circle (8)

But it looks like it currently leaves this:

  1. Circle (1)
  2. Circle (3)
  3. Circle (5)
  4. Circle (6)
  5. Circle (7)
  6. Circle (8)

Ungrouping items sometimes messes up selections

Not yet sure of exactly what's going on, but it looks like any items that are selected within the group go wrong - presumably their .selected property is remaining set, but they are not actually listed within the new .selection list..?

Create an 'area' or 'bounding-box' object

Should have left, right, top, bottom, width & height properties, which auto-update when one is changed.

Would be great if it were possible to link to (some of) these attributes somehow - eg so that a group's left was actually just a link to the left-most item's left, so that as the group gets moved around the group's left automatically follows the item's left, with no additional work. (similar to the concept of how mouse.dragOffset works)

Item.count includes the top-level group, which is misleading...

If you delete everything, then Item.count == 1... Technically this is correct, but it's a misleading piece of information.
Alternatively, maybe we want to add indicators of how many items there are in the current view (plus in the current selection would be nice!)..?

Explore: Do we really need to still keep a Selection list..?

It would help to reduce the chance of conflicts (like Issue #24) if we had either a Selection list or .selected flags - not both. .selected flags reduce/remove the need to call Selection.indexOf() - which I believe speeds things up a little bit for frequently called functions like draw(). If we got rid of the Selection list then various operations would need to iterate through the entire group to find the currently selected items, which will be (a little bit) slower - but if these are only called occasionally then that's not too much of a concern...

Would it still be useful to keep a count of selected items (for Selection.any() for example), or is that still (in effect) leaving room for conflicting information..?

Add a short delay before showing 'move' cursor when clicking

Currently a simple click causes the 'move' cursor to appear briefly. If we could add a delay before showing it (0.5s? 0.2s?) that would be nicer. At the same time, if the cursor actually moves (between a mousedown event and a mouseup event) then it should instantly change to a 'move' cursor!..

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.