Code Monkey home page Code Monkey logo

boxes-on-canvas's Introduction

Build Status Coverage Status js-standard-style Codacy Badge

Boxes on Canvas (2D)

The App draws boxes (rectangles) on a web page and allows an User to drag & drop them. The app was developed within my JS practices (Modules, Bundler, TDD, CI).

Requirements

Canvas is used to render shapes. The draw area has size of the page viewport with some padding. Several rectangles of different sizes are displayed on the page load one under the other. An end User can drag & drop shapes via a mouse.

If a shape intersects with other shapes during the mouse move event then all intersecting shapes should change the color in red. Mouse up event is allowed only if none of shapes intersect with draggable one. Otherwise the draggable shapes gets back to the initial position.

A shape can be snapped to the nearest one on moving action. Snapping occurs when any side of a shape being moved approaches a side of other shape closer then a distance <= X. Shapes get positioned close to each other in relation of bordering edges. In order to split shapes a User should drag a shape on a distance > X. Snapping should work in a way to avoid shapes intersections.

There should be a canvas with rectangles of different sizes one under the other on the page load.

The app should not use any 3d party libs.

Installation

  1. Checkout git repository
  2. Run npm install to install dependencies
  3. Run npm run test to test the App
  4. Run npm run build to build the App
  5. Run npm run karma to run visual tests
  6. Open dist/index.html in a Browser (preferably in Chrome)

User Guide

Drag and drop rectangles.

Contributing

Source code is located in src folder. Tests are in spec and visualSpec folders (see the TDD section).

The codebase uses ESModule definition. During the development it is productive to see the results of you feature. To enable live rebuild start Webpack Dev server by command npm run start.

Run npm run dev to build the app with source maps enabled.

TDD

Jasmine is used as a testing framework. Karma is used to run browser specific tests.

In case you're adding a business logic with no dependency on a window object then you add test with no web browser required. These tests are in spec folder. The command to run tests is npm run test

If your feature requires a Web Browser then you'll have to add tests to visualSpec folder. The command to run tests is npm run karma. Open visualSpec/index.html to run visual tests.

Once a feature is done make sure the code passes ES Lint. Run npm run cs-fix-src or npm run cs-fix-spec

Todo List

  • release version 1
  • add Karma to Travis CI
  • enable animation in boxApp
  • refactor the App in more Event Driven Approach
  • split webpack prod/test config
  • rethink Babel usage
  • refactor console.log calls
  • add demos on github pages
  • add generated docuementation

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.