Coder Social home page Coder Social logo

skaterdad / cycle-snabbdom-examples Goto Github PK

View Code? Open in Web Editor NEW
13.0 3.0 2.0 854 KB

Cycle.js Component Examples with Routing & Transitions!

License: MIT License

CSS 18.16% JavaScript 79.65% HTML 2.18%
cyclejs hero-transition xstream examples

cycle-snabbdom-examples's Introduction

Cycle version & Stream Library

This branch uses Cycle Diversity w/ xstream.

cycle-snabbdom-examples

Examples using Cycle.js with Snabbdom as the v-dom library (this is now default).

Examples

  1. Color Changer - Basically just a counter app, but background color changes by looping through an array.
  2. Redirect After Form Post - Shows one way of handling URL redirects after <form> posts.
  3. Github Search - Clone of official Cycle example, with snabbdom-specific animations as search results are added/removed.
  4. Hero Transition (Simple) - Checkbox toggles between pages. Each page is a box with some text. The text does a hero transition.
  5. Hero Transition (Complex) - 1st page pulls repo list from github. 2nd page is detail for a specific repo. The owner avatar does a hero transition.
  6. Hero Transition (Tests) - Hero transitions on multiple types of DOM elements, including text which changes orientation and size. Best viewed in Chrome. Other browsers have problems with one of the text transitions.

snabbdom-specific animations

  • Route/Page transitions - currently just opacity fade, but you can easily extend to add transforms. The important part is that your page wrappers are position: absolute so they can overlap while transitioning.
  • Search result items animate when added & removed.
  • Hero transitions (aka. shared element transitions). An item which is common to two pages will smoothly animate to the new position. This relies on the snabbdom hero module, so you'll need to pass a list of modules to the Cycle DOM driver.

Future plans

  • Document how some of these examples work in more detail. There is a careful balance of position: relative and position: absolute on certain elements and containers.

How to use

For client-side hot reloading:

  1. Clone the repo
  2. Choose a branch
  3. npm install
  4. npm start
  5. Open your browser to http://localhost:3000/

cycle-snabbdom-examples's People

Contributors

skaterdad avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

cycle-snabbdom-examples's Issues

HTTP requests go crazy when re-entering that example

The project currently contains two example apps, which are implemented as nested dialogues. You can toggle between them, similar to how the routes are toggle in cycle-starter.

The following steps produce a nasty bug (open the browser network monitor in dev tools):

  1. Go to the Github search example and do a couple searches. You should see one request being sent per search, possibly some canceled requests depending on how fast you type (it has a 500ms delay).
  2. Switch back to the Color Changer example.
  3. Go back to the Github search example. Bug #1 is that this page fires off a request right away (duplicate of the last one you did before leaving the page, this issue will be fixed later). Bug #2 is that new searches will fire off 4 times at once. Github's API server doesn't like it, so tread carefully to avoid errors.
  4. If you repeat this process, you'll end up with the searches firing off 8 at once.

Is anyone able to shed some light on this? I am new to Rx and Cycle, so I feel like I'm missing something fundamental.

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.