Git Product home page Git Product logo

applepienav's Introduction

Apple Pie Nav

A hyper-quick pie-menu method action system.

Feedback would be much appreciated, questions, suggestions, issues are more than welcome.

MIT License

How it works

When implemented, this navigation component lets you press a hotkey (default: spacebar) which immediately brings up a pie-like navigation component. It tries to center around the mouse center, but adjusts given certain rules so that all options remain visible. While the hotkey is depressed, user can simply move the mouse over the desired zone and release the hotkey. The associated method (typically navigation, but could be anything) will then fire, and the component will hide.

Demo

A usage demo gif

Usage

In your own Vue scripts:

<template>
  <div>
    <ApplePie trigger="s" :zones="zones" />
  </div>
</template>

<script>
import ApplePie from 'ApplePieNav.vue'
export default {
  components: [ApplePie],
  data() {
    return {
      zones: [
        {
          label: 'Pizza',
          exec: () => {
            console.log('This is a direct method')
          }
        },
        {
          label: 'Beer',
          exec: this.sayBeer
        }
      ]
    }
  },
  methods: {
    sayBeer() {
      console.log('To drink or not to drink...')
    }
  }
}
</script>

Options

Vue component parameters:

Parameter Purpose Default
trigger Mousetrap key string to activate the navigation pie. 'space'
zones Array of zone options. This expects between 3 and 9 zones. If fewer or more are given, they're spread or trimmed. You'll see. Array(3).fill({ label: 'Undefined Zone', exec: () => {} })
mask Integer radius in pixels of the central zone mask circle where actions are ignored. 70
buffer How much space to put between the edge of the mask and the zone labels in pixels. 150
margin How much of a margin to leave around the inside of the main window so the pie doesn't render too close to the outside which would hide some options. 300

Features

  • Prevents the pie from starting too close to the window's margin if the mouse is within said margin. This is good because it prevents options from being hidden.
  • Automatically limits the number of options passed in to between 3 and 9 because, really... What do you need a pie nav for fewer or more at one time?
  • Allows as many different pie navs to be loaded as you wish. Just associate them with different trigger keys and you can have multiple hyper menus available in your system.

Dependencies

To capture and react to user keypresses

To make things look nice in a way that makes sense.

Inspiration

I started building 3D scenes with Blender and had my mind blown by their implementation of rapid navigation with their pie menus. I honestly believe it's one of the fastest ways to navigate to different pages in a user interface because it allows you to simply gesture with your trackpad or mouse which is far simpler than hunting down a small-target menu item to get to your destination.

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.