Giter VIP home page Giter VIP logo

react-osx-dock's Introduction

react-osx-dock npm version

React component that is magnifiable like the Mac OS X dock.

Works in any Web browser that supports CSS grid and flexbox layout.

View a demo here.

Installation

Install the package with NPM:

npm install react-osx-dock

Usage

Example:

import { Dock } from 'react-osx-dock';

<Dock itemWidth={50} magnification={2} magnifyDirection="up">
  {['A', 'B', 'C', 'D', 'E', 'F', 'G'].map((letter) => (
    <img
      className="letter"
      src={`${letter}.png`}
      onClick={() => console.log(letter)}
      key={letter}
    />
  ))}
</Dock>

API

The Dock component has the following props:

Name Description Type Required
itemWidth The default (i.e. unmagnified) width of dock items in pixels. number yes
magnification The % amount of dock item magnification produced on mouse-over. number yes
magnifyDirection The vertical direction that dock items grow when magnified. string enum

("up", "down", "center")
yes
className The dock's CSS class. string no

default: undefined
backgroundClassName The dock background's CSS class. string no

default: undefined
debug Whether to render dock bounding boxes or not. Useful for debugging! boolean no

default: false

Any children provided to the Dock component will be considered "dock items" and wrapped accordingly to facilitate the magnification behavior.

Credits

The demo website uses a couple of free icon packs from FlatIcon:

Thanks!

react-osx-dock's People

Contributors

lukehorvat avatar nattatorn-dev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-osx-dock's Issues

Hovering in/out Animation Easing

Hey! Very cool react component

Are there plans in the pipeline for easing the transition from hovering into and out of bounds?

Doesn't work

Cool idea and the demo works but I get no scaling when I hover with the quickstart code. I can see it hasn't been updated in a couple years but in future projects, please provide quickstart code that works, and/or don't minify the working demo in gh-pages please.

hover trigger is offset to left

far right dock items are not interactive (maginiable ) onclick works but they wont maginfy when mouse is over. plus maginication area of far left trigger maginification even when not directly over the dock items . it seems there is some kind of offset.
here is my file
<Dock width={400} magnification={2} magnifyDirection="up" debug={true} className="dock" backgroundClassName="dock-background"> {["a", "b", "c", "d", "e"].map((item, index) => ( <Dock.Item className="dock.item" key={index} onClick={() => console.log(item)}> <img src={${item}.png} /> </Dock.Item> ))} </Dock>

it works as expected if i set the width to 800 but its too big for me

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.