Code Monkey home page Code Monkey logo

kinetica's Introduction

Kinetica

Unprecedented kinetic engine.

NPM version bitHound Overall Score js-standard-style

Table of Contents

Features

  • Designed with performance in mind
  • Lightweight - 10.4 KB
  • Mobile friendly - supports mouse events, touch events and pointer events

Dependencies

Install

Download dev or prod version and put it in your html

<script src="vendor/kinetic.min.js"></script>

Usage

// start the digest loop
requestAnimationFrame(function loop (t) {
  Kinetic.notify(t)
  requestAnimationFrame(loop)
})

// create kinetic instance
var kinetic = new Kinetic({
  el: document.body,
  Vector: Vector
})

// spawn it
Kinetic.spawn(kinetic)

// implement scroll
var $target = document.getElementById('container')

var position = new Vector(0, 0)

function scrollTo (position) {
  $target.style.transform = `translateY(${position.y}px)`
}

function isValidScroll (position) {
  return position.y <= 0 && position.y > -5000 + window.innerHeight
}

function scrollY (pointers) {
  if (pointers.length === 1) {
    var pointer = pointers[0]
    var next = position.add(pointer.delta)
    if (isValidScroll(next)) {
      scrollTo(next)
      position = next
    }
  }
}

// subscribe to kinetic
kinetic.subscribe(scrollY)

Examples

API

Development

Command Description
npm run check Check standard code style by snazzy
npm run build Wrap source code in UMD by rollup
npm run min Minify code by UglifyJS

kinetica's People

Contributors

broadsw0rd avatar

Stargazers

 avatar

Watchers

 avatar

kinetica's Issues

Examples

  • Scroll Y
  • Scroll X
  • Scroll XY
  • Scale
  • Rotate

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.