Code Monkey home page Code Monkey logo

floaty's Introduction

Floaty.js

Floaty is a pure JavaScript, mobile friendly library for adding dynamic, floating elements to your webpage. The behavior of the elements that you choose as Floaties is similar to Apple's assistive touch or Facebook's chat head bubbles.

Demo

Floaty Demo Gif

What's in the Works?

  • Documenting API
  • Create more complicated examples
  • More extensive testing

What's New?

  • New ES6 source code
  • Giving users the choice of lifecycle, i.e. when to initialize all Floaties
  • Added method for dynamically adding Floaties

Quick Start Guide

To use Floaty.js, include floaty.js and floaty.css in your webpage project.

<script type="text/javascript" src="https://raw.githubusercontent.com/tylermzeller/floaty/master/floaty.js"></script>
<link rel="stylesheet" type="text/css" href="https://raw.githubusercontent.com/tylermzeller/floaty/master/floaty.css">

Then add a floaty class to the elements you wish to become Floaties.

<div class="floaty"></div>

Currently the only option to customize the appearance of your Floaty is through CSS.

div.floaty {
  width: 50px;
  height: 50px;
  border-radius: 100%; /* circular */
  background-color: pink;
  top: 50%; /* Starting y position */
  left: 0; /* Starting x position */
}

In your own script file, choose when to initialize your Floaties. If you wanted to initialize them when the DOM content loads, this is what that would look like:

let floatyInit = () => {
  let floaties = Floaty.init()
  // ... use floaties, or don't
  Floaty.addFloaty('new') // you can even add floaties dynamically
}

if (document.readyState === 'loading') {
  document.addEventListener('DOMContentLoaded', floatyInit)
} else {
  floatyInit()
}

That's it! Enjoy and have fun!

floaty's People

Contributors

tylermzeller avatar

Stargazers

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

Watchers

 avatar

floaty's Issues

Issue iPhone Safari+Chrome

Hi @tylermzeller,

I'm sure you left this behind a long time ago, at least it seems so form the dates on Github... so I understand if you don't have time or feel like working with old projects, but I'm going to try my luck!

ISSUE
I have set-up a raw and clean stage in a Pen inside Codepen.
Implementing only your script and stylesheet ('raw code' to eliminate external issues), plus initiating both through script and by a div.floaty in html and it's not activating on iPhone (chrome or safari)... it's working on desktop just fine in the same browsers.
I also tried debugging cabled to iPhone via Safari, without luck.

If possible, can I get you to have a look and tell me what's wrong - I'm getting crazy here, - used several days on this now.

STAGE:
Front-end: https://codepen.io/philipsacht/full/mdwaNjq
Backend (editable): https://codepen.io/philipsacht/pen/mdwaNjq

THANK YOU
🤞🤞🤞🤞

Philip F Sacht

handle event resize window

After i resize window, the floaty element will display not correct.
and i think, floaty should be support display in div wrapper

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.